Here are the examples of the csharp api NUnit.Framework.Assert.That(bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
188 Examples
19
Source : FieldTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentSize()
{
var field1 = new Field { Size = FieldSize.Bit1, Type = FieldType.MemoryAddress, Value = 0x1234 };
var field2 = new Field { Size = FieldSize.Bit2, Type = FieldType.MemoryAddress, Value = 0x1234 };
replacedert.That(field1, Is.Not.EqualTo(field2));
replacedert.That(field1 != field2);
replacedert.That(!field1.Equals(field2));
}
19
Source : FieldTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentType()
{
var field1 = new Field { Size = FieldSize.Byte, Type = FieldType.MemoryAddress, Value = 0x1234 };
var field2 = new Field { Size = FieldSize.Byte, Type = FieldType.PreviousValue, Value = 0x1234 };
replacedert.That(field1, Is.Not.EqualTo(field2));
replacedert.That(field1 != field2);
replacedert.That(!field1.Equals(field2));
}
19
Source : FieldTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentAddress()
{
var field1 = new Field { Size = FieldSize.Byte, Type = FieldType.MemoryAddress, Value = 0x1234 };
var field2 = new Field { Size = FieldSize.Byte, Type = FieldType.MemoryAddress, Value = 0x1235 };
replacedert.That(field1, Is.Not.EqualTo(field2));
replacedert.That(field1 != field2);
replacedert.That(!field1.Equals(field2));
}
19
Source : FieldTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentValue()
{
var field1 = new Field { Size = FieldSize.Byte, Type = FieldType.Value, Value = 0x1234 };
var field2 = new Field { Size = FieldSize.Byte, Type = FieldType.Value, Value = 0x1235 };
replacedert.That(field1, Is.Not.EqualTo(field2));
replacedert.That(field1 != field2);
replacedert.That(!field1.Equals(field2));
}
19
Source : FieldTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentSizeValue()
{
// Size should be ignored when comparing two Value fields, all Value fields are 32-bit in the runtime
var field1 = new Field { Size = FieldSize.Byte, Type = FieldType.Value, Value = 8 };
var field2 = new Field { Size = FieldSize.Word, Type = FieldType.Value, Value = 8 };
replacedert.That(field1, Is.EqualTo(field2));
replacedert.That(field1 == field2);
replacedert.That(field1.Equals(field2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEquals()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
replacedert.That(requirement1, Is.EqualTo(requirement2));
replacedert.That(requirement1 == requirement2);
replacedert.That(requirement1.Equals(requirement2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentLeft()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte2345), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
replacedert.That(requirement1, Is.Not.EqualTo(requirement2));
replacedert.That(requirement1 != requirement2);
replacedert.That(!requirement1.Equals(requirement2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentRight()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Byte2345) };
replacedert.That(requirement1, Is.Not.EqualTo(requirement2));
replacedert.That(requirement1 != requirement2);
replacedert.That(!requirement1.Equals(requirement2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentOperator()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.GreaterThanOrEqual, Right = GetField(TestField.Value99) };
replacedert.That(requirement1, Is.Not.EqualTo(requirement2));
replacedert.That(requirement1 != requirement2);
replacedert.That(!requirement1.Equals(requirement2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentType()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99), Type = RequirementType.PauseIf };
replacedert.That(requirement1, Is.Not.EqualTo(requirement2));
replacedert.That(requirement1 != requirement2);
replacedert.That(!requirement1.Equals(requirement2));
}
19
Source : RequirementTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestEqualsDifferentHitCount()
{
var requirement1 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99) };
var requirement2 = new Requirement { Left = GetField(TestField.Byte1234), Operator = RequirementOperator.Equal, Right = GetField(TestField.Value99), HitCount = 1 };
replacedert.That(requirement1, Is.Not.EqualTo(requirement2));
replacedert.That(requirement1 != requirement2);
replacedert.That(!requirement1.Equals(requirement2));
}
19
Source : IndexedVariableExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var variable = new VariableExpression("variable1");
var index = new VariableExpression("variable2");
var expr = new IndexedVariableExpression(variable, index);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(2));
replacedert.That(nested.Contains(variable));
replacedert.That(nested.Contains(index));
}
19
Source : ArrayExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var variable1 = new VariableExpression("variable1");
var variable2 = new VariableExpression("variable2");
var value1 = new IntegerConstantExpression(98);
var value2 = new IntegerConstantExpression(99);
var value3 = new IntegerConstantExpression(1);
var expr = new ArrayExpression();
expr.Entries.Add(variable1);
expr.Entries.Add(value1);
expr.Entries.Add(variable2);
expr.Entries.Add(value2);
expr.Entries.Add(value3);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(5));
replacedert.That(nested.Contains(variable1));
replacedert.That(nested.Contains(variable2));
replacedert.That(nested.Contains(value1));
replacedert.That(nested.Contains(value2));
replacedert.That(nested.Contains(value3));
}
19
Source : ArrayExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var variable1 = new VariableExpression("variable1");
var variable2 = new VariableExpression("variable2");
var value1 = new IntegerConstantExpression(98);
var value2 = new IntegerConstantExpression(99);
var value3 = new IntegerConstantExpression(1);
var expr = new ArrayExpression();
expr.Entries.Add(variable1);
expr.Entries.Add(value1);
expr.Entries.Add(variable2);
expr.Entries.Add(value2);
expr.Entries.Add(value3);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("variable1"));
replacedert.That(dependencies.Contains("variable2"));
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var variable = new VariableExpression("variable");
var value = new IntegerConstantExpression(99);
var expr = new replacedignmentExpression(variable, value);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(2));
replacedert.That(nested.Contains(variable));
replacedert.That(nested.Contains(value));
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var variable = new VariableExpression("variable1");
var value = new VariableExpression("variable2");
var expr = new replacedignmentExpression(variable, value);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(1));
replacedert.That(dependencies.Contains("variable1"), Is.False); // variable1 is replacedigned, not read from
replacedert.That(dependencies.Contains("variable2"));
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependenciesUpdateSelf()
{
var variable = new VariableExpression("variable1");
var value = new IntegerConstantExpression(1);
var mathematic = new MathematicExpression(variable, MathematicOperation.Add, value);
var expr = new replacedignmentExpression(variable, mathematic);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(1));
replacedert.That(dependencies.Contains("variable1")); // variable1 is read from before it's replacedigned
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependenciesIndexed()
{
var variable = new VariableExpression("variable1");
var value = new VariableExpression("variable2");
var indexed = new IndexedVariableExpression(variable, value);
var expr = new replacedignmentExpression(indexed, value);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(1));
replacedert.That(dependencies.Contains("variable1"), Is.False); // variable1 is updated
replacedert.That(dependencies.Contains("variable2")); // variable2 is needed to get the index
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependenciesMultiIndexed()
{
// variable1[variable2][variable3] = 1
var variable1 = new VariableExpression("variable1");
var variable2 = new VariableExpression("variable2");
var variable3 = new VariableExpression("variable3");
var indexed1 = new IndexedVariableExpression(variable1, variable2);
var indexed2 = new IndexedVariableExpression(indexed1, variable3);
var value = new IntegerConstantExpression(1);
var expr = new replacedignmentExpression(indexed2, value);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("variable1"), Is.False); // variable1 is updated
replacedert.That(dependencies.Contains("variable2")); // variable2 is needed to get the index
replacedert.That(dependencies.Contains("variable3")); // variable3 is needed to get the index
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependenciesNestedIndexed()
{
// variable1[variable2[variable3]] = 1
var variable1 = new VariableExpression("variable1");
var variable2 = new VariableExpression("variable2");
var variable3 = new VariableExpression("variable3");
var indexed1 = new IndexedVariableExpression(variable2, variable3);
var indexed2 = new IndexedVariableExpression(variable1, indexed1);
var value = new IntegerConstantExpression(1);
var expr = new replacedignmentExpression(indexed2, value);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("variable1"), Is.False); // variable1 is updated
replacedert.That(dependencies.Contains("variable2")); // variable2 is needed to get the index
replacedert.That(dependencies.Contains("variable3")); // variable3 is needed to get the index
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModifications()
{
var variable = new VariableExpression("variable1");
var value = new VariableExpression("variable2");
var expr = new replacedignmentExpression(variable, value);
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("variable1"));
replacedert.That(modifications.Contains("variable2"), Is.False); // variable2 is read from, not modified
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModificationsUpdateSelf()
{
var variable = new VariableExpression("variable1");
var value = new IntegerConstantExpression(1);
var mathematic = new MathematicExpression(variable, MathematicOperation.Add, value);
var expr = new replacedignmentExpression(variable, mathematic);
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("variable1"));
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModificationsIndexed()
{
var variable = new VariableExpression("variable1");
var index = new VariableExpression("variable2");
var indexed = new IndexedVariableExpression(variable, index);
var value = new IntegerConstantExpression(1);
var expr = new replacedignmentExpression(indexed, value);
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("variable1")); // variable1 is updated
replacedert.That(modifications.Contains("variable2"), Is.False); // index variable is not updated
}
19
Source : AssignmentExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModificationsMultiIndexed()
{
// variable1[variable2][variable3] = 1
var variable = new VariableExpression("variable1");
var index1 = new VariableExpression("variable2");
var index2 = new VariableExpression("variable3");
var indexed1 = new IndexedVariableExpression(variable, index1);
var indexed2 = new IndexedVariableExpression(indexed1, index2);
var value = new IntegerConstantExpression(1);
var expr = new replacedignmentExpression(indexed2, value);
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("variable1")); // variable1 is updated
replacedert.That(modifications.Contains("variable2"), Is.False); // index variable is not updated
replacedert.That(modifications.Contains("variable3"), Is.False); // index variable is not updated
}
19
Source : DictionaryExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestReplaceVariablesCreatesCopy()
{
var key1 = new IntegerConstantExpression(1);
var key2 = new IntegerConstantExpression(2);
var value1 = new StringConstantExpression("One");
var value2 = new StringConstantExpression("Two");
var dict1 = new DictionaryExpression();
dict1.Add(key1, value1);
dict1.Add(key2, value2);
var scope = new InterpreterScope();
ExpressionBase result;
replacedert.That(dict1.ReplaceVariables(scope, out result), Is.True);
replacedert.That(result, Is.InstanceOf<DictionaryExpression>());
var dict2 = (DictionaryExpression)result;
replacedert.That(dict2.Count, Is.EqualTo(2));
// item added to original dictionary does not appear in evaluated dictionary
var key3 = new IntegerConstantExpression(3);
var value3 = new StringConstantExpression("Three");
dict1.Add(key3, value3);
replacedert.That(dict1.Count, Is.EqualTo(3));
replacedert.That(dict2.Count, Is.EqualTo(2));
// item added to evaluated dictionary does not appear in original dictionary
var key4 = new IntegerConstantExpression(4);
var value4 = new StringConstantExpression("Four");
dict2.Add(key4, value4);
replacedert.That(dict1.Count, Is.EqualTo(3));
replacedert.That(dict2.Count, Is.EqualTo(3));
replacedert.That(dict1.Keys.Contains(key3));
replacedert.That(!dict2.Keys.Contains(key3));
replacedert.That(!dict1.Keys.Contains(key4));
replacedert.That(dict2.Keys.Contains(key4));
}
19
Source : DictionaryExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var key1 = new VariableExpression("key1");
var value1 = new IntegerConstantExpression(99);
var key2 = new StringConstantExpression("key2");
var value2 = new VariableExpression("value2");
var expr = new DictionaryExpression();
expr.Add(key1, value1);
expr.Add(key2, value2);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(4));
replacedert.That(nested.Contains(key1));
replacedert.That(nested.Contains(value1));
replacedert.That(nested.Contains(key2));
replacedert.That(nested.Contains(value2));
}
19
Source : DictionaryExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var key1 = new VariableExpression("key1");
var value1 = new IntegerConstantExpression(99);
var key2 = new StringConstantExpression("key2");
var value2 = new VariableExpression("value2");
var expr = new DictionaryExpression();
expr.Add(key1, value1);
expr.Add(key2, value2);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("key1"));
replacedert.That(dependencies.Contains("value2"));
}
19
Source : ExpressionGroupTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestAddExpression()
{
var group = new ExpressionGroup();
replacedert.That(group.Expressions, Is.Empty);
replacedert.That(group.ParseErrors, Is.Empty);
replacedert.That(group.IsEmpty);
var integerConstantExpression = new IntegerConstantExpression(3);
group.AddExpression(integerConstantExpression);
replacedert.That(!group.IsEmpty);
replacedert.That(group.Expressions.Count(), Is.EqualTo(1));
replacedert.That(group.Expressions.Contains(integerConstantExpression));
replacedert.That(group.ParseErrors, Is.Empty);
var replacedignmentExpression = new replacedignmentExpression(new VariableExpression("v"), new IntegerConstantExpression(6));
group.AddExpression(replacedignmentExpression);
replacedert.That(!group.IsEmpty);
replacedert.That(group.Expressions.Count(), Is.EqualTo(2));
replacedert.That(group.Expressions.Contains(integerConstantExpression));
replacedert.That(group.Expressions.Contains(replacedignmentExpression));
replacedert.That(group.ParseErrors, Is.Empty);
}
19
Source : ExpressionGroupTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestAddParseError()
{
var group = new ExpressionGroup();
replacedert.That(group.Expressions, Is.Empty);
replacedert.That(group.ParseErrors, Is.Empty);
replacedert.That(group.IsEmpty);
var parseError = new ParseErrorExpression("oops");
group.AddParseError(parseError);
replacedert.That(group.ParseErrors.Count(), Is.EqualTo(1));
replacedert.That(group.ParseErrors.Contains(parseError));
replacedert.That(group.Expressions, Is.Empty);
replacedert.That(!group.IsEmpty);
var parseError2 = new ParseErrorExpression("bad");
group.AddParseError(parseError2);
replacedert.That(group.ParseErrors.Count(), Is.EqualTo(2));
replacedert.That(group.ParseErrors.Contains(parseError));
replacedert.That(group.ParseErrors.Contains(parseError2));
replacedert.That(group.Expressions, Is.Empty);
replacedert.That(!group.IsEmpty);
}
19
Source : ExpressionGroupTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestUpdateMetadata()
{
var group = Parse("a = 3").Groups.First(); // Parse will call UpdateMetadata
replacedert.That(group.IsEmpty, Is.False);
replacedert.That(group.FirstLine, Is.EqualTo(1));
replacedert.That(group.LastLine, Is.EqualTo(1));
replacedert.That(group.ParseErrors, Is.Empty);
replacedert.That(group.Expressions, Is.Not.Empty);
replacedert.That(group.IsDependentOn("a"), Is.False);
replacedert.That(group.Modifies.Contains("a"));
}
19
Source : IndexedVariableExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var variable = new VariableExpression("variable1");
var index = new VariableExpression("variable2");
var expr = new IndexedVariableExpression(variable, index);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("variable1"));
replacedert.That(dependencies.Contains("variable2"));
}
19
Source : ReturnExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var variable = new VariableExpression("variable");
var expr = new ReturnExpression(variable);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(1));
replacedert.That(nested.Contains(variable));
}
19
Source : ReturnExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var variable = new VariableExpression("variable");
var expr = new ReturnExpression(variable);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(1));
replacedert.That(dependencies.Contains("variable"));
}
19
Source : RegressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
[TestCaseSource(typeof(RegressionTestFactory), "Files")]
public void RegressionTest(string scriptFileName, string scriptPath)
{
if (scriptFileName == NoScriptsError)
return;
var parts = scriptPath.Split('\\');
int i = 0;
if (!Path.IsPathRooted(scriptPath))
{
scriptPath = Path.Combine(RegressionDir, scriptPath);
}
else
{
while (parts[i] != "Regressions")
{
++i;
replacedert.That(i < parts.Length);
}
++i;
replacedert.That(i < parts.Length);
}
if (parts[i] == "scripts")
++i;
var expectedFileName = Path.GetFileNameWithoutExtension(scriptPath);
while (i < parts.Length - 1)
{
expectedFileName += "-" + parts[i];
++i;
}
expectedFileName = Path.Combine(RegressionDir, "results", expectedFileName + ".txt");
var outputFileName = Path.ChangeExtension(expectedFileName, ".updated.txt");
var interpreter = new AchievementScriptInterpreter();
interpreter.Run(Tokenizer.CreateTokenizer(File.Open(scriptPath, FileMode.Open)));
if (!String.IsNullOrEmpty(interpreter.ErrorMessage))
{
using (var file = File.Open(outputFileName, FileMode.Create))
{
using (var fileWriter = new StreamWriter(file))
fileWriter.Write(interpreter.ErrorMessage);
}
if (!File.Exists(expectedFileName))
replacedert.IsNull(interpreter.ErrorMessage);
}
else
{
var mockFileSystemService = new Mock<IFileSystemService>();
mockFileSystemService.Setup(s => s.CreateFile(It.IsAny<string>())).Returns((string path) => File.Create(path));
var localAchievements = new LocalAchievements(outputFileName, mockFileSystemService.Object);
localAchievements.replacedle = Path.GetFileNameWithoutExtension(scriptFileName);
foreach (var achievement in interpreter.Achievements)
localAchievements.Replace(null, achievement);
localAchievements.Commit("Author", null, null);
if (interpreter.Leaderboards.Any())
{
using (var file = File.Open(outputFileName, FileMode.Append))
{
using (var fileWriter = new StreamWriter(file))
{
fileWriter.WriteLine("=== Leaderboards ===");
foreach (var leaderboard in interpreter.Leaderboards)
{
fileWriter.Write("0:");
fileWriter.Write("\"STA:");
fileWriter.Write(leaderboard.Start);
fileWriter.Write("::CAN:");
fileWriter.Write(leaderboard.Cancel);
fileWriter.Write("::SUB:");
fileWriter.Write(leaderboard.Submit);
fileWriter.Write("::VAL:");
fileWriter.Write(leaderboard.Value);
fileWriter.Write("\":");
fileWriter.Write(leaderboard.Format);
fileWriter.Write(":\"");
fileWriter.Write(leaderboard.replacedle);
fileWriter.Write("\":\"");
fileWriter.Write(leaderboard.Description);
fileWriter.WriteLine("\"");
}
}
}
}
if (!String.IsNullOrEmpty(interpreter.RichPresence))
{
using (var file = File.Open(outputFileName, FileMode.Append))
{
using (var fileWriter = new StreamWriter(file))
{
fileWriter.WriteLine("=== Rich Presence ===");
if (Double.Parse(localAchievements.Version) < 0.79)
{
interpreter.RichPresenceBuilder.DisableLookupCollapsing = true;
fileWriter.WriteLine(interpreter.RichPresenceBuilder.ToString());
}
else
{
fileWriter.WriteLine(interpreter.RichPresence);
}
}
}
}
replacedert.IsTrue(File.Exists(expectedFileName), expectedFileName + " not found");
}
var expectedFileContents = File.ReadAllText(expectedFileName);
var outputFileContents = File.ReadAllText(outputFileName);
// file didn't match, report first difference
if (expectedFileContents != outputFileContents)
{
var expectedFileTokenizer = Tokenizer.CreateTokenizer(expectedFileContents);
var outputFileTokenizer = Tokenizer.CreateTokenizer(outputFileContents);
var line = 1;
do
{
var expectedFileLine = expectedFileTokenizer.ReadTo('\n').TrimRight();
var outputFileLine = outputFileTokenizer.ReadTo('\n').TrimRight();
if (expectedFileLine != outputFileLine)
replacedert.AreEqual(expectedFileLine.ToString(), outputFileLine.ToString(), "Line " + line);
expectedFileTokenizer.Advance();
outputFileTokenizer.Advance();
++line;
} while (expectedFileTokenizer.NextChar != '\0' || outputFileTokenizer.NextChar != '\0');
// failed to find differing line, fallback to nunit replacedertion
Filereplacedert.AreEqual(expectedFileName, outputFileName);
}
// file matched, delete temporary file
File.Delete(outputFileName);
}
19
Source : ForExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var expr = Parse("for a in [b,c] { d = a }");
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("a"), Is.False); // iterator is self-contained
replacedert.That(dependencies.Contains("b"));
replacedert.That(dependencies.Contains("c"));
replacedert.That(dependencies.Contains("d"), Is.False); // replacedignment, not read
}
19
Source : ForExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModifications()
{
var expr = Parse("for a in [b,c] { d = a }");
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("a"), Is.False); // iterator is self-contained
replacedert.That(modifications.Contains("b"), Is.False); // read, not modified
replacedert.That(modifications.Contains("c"), Is.False); // read, not modified
replacedert.That(modifications.Contains("d"));
}
19
Source : FunctionCallExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var parameter = new VariableExpression("variable1");
var name = new FunctionNameExpression("func");
var expr = new FunctionCallExpression(name, new ExpressionBase[] { parameter });
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(2));
replacedert.That(nested.Contains(name));
replacedert.That(nested.Contains(parameter));
}
19
Source : FunctionCallExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var parameter = new VariableExpression("variable1");
var name = new FunctionNameExpression("func");
var expr = new FunctionCallExpression(name, new ExpressionBase[] { parameter });
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("func"));
replacedert.That(dependencies.Contains("variable1"));
}
19
Source : FunctionDefinitionExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var expr = Parse("function func(i) => func2(i) + j");
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("func2"));
replacedert.That(dependencies.Contains("j"));
replacedert.That(dependencies.Contains("i"), Is.False); // parameter is self-contained
}
19
Source : FunctionDefinitionExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModifications()
{
var expr = Parse("function func(i) => func2(i) + j");
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("func"));
}
19
Source : FunctionDefinitionExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModifications2()
{
var expr = Parse("function func(i) {\n" +
" j = func2(i)\n" +
" i = j + 3\n" +
" return i\n" +
"}");
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(2));
replacedert.That(modifications.Contains("func"));
replacedert.That(modifications.Contains("j"));
replacedert.That(modifications.Contains("i"), Is.False); // parameter is self-contained
}
19
Source : IfExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var expr = Parse("if (a == 3) { b = c + 4 } else { d = e }");
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(3));
replacedert.That(dependencies.Contains("a"));
replacedert.That(dependencies.Contains("c"));
replacedert.That(dependencies.Contains("e"));
}
19
Source : IfExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetModifications()
{
var expr = Parse("if (a == 3) { b = c + 4 } else { d = e }");
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(2));
replacedert.That(modifications.Contains("b"));
replacedert.That(modifications.Contains("d"));
}
19
Source : VariableExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestDefinitionGetModifications()
{
var expr = new VariableDefinitionExpression("variable1");
var modifications = new HashSet<string>();
((INestedExpressions)expr).GetModifications(modifications);
replacedert.That(modifications.Count, Is.EqualTo(1));
replacedert.That(modifications.Contains("variable1"));
}
19
Source : LeftRightExpressionBaseTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestNestedExpressions()
{
var left = new VariableExpression("variable1");
var right = new VariableExpression("variable2");
var expr = new LeftRightExpression(left, right);
var nested = ((INestedExpressions)expr).NestedExpressions;
replacedert.That(nested.Count(), Is.EqualTo(2));
replacedert.That(nested.Contains(left));
replacedert.That(nested.Contains(right));
}
19
Source : LeftRightExpressionBaseTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var left = new VariableExpression("variable1");
var right = new VariableExpression("variable2");
var expr = new LeftRightExpression(left, right);
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(2));
replacedert.That(dependencies.Contains("variable1"));
replacedert.That(dependencies.Contains("variable2"));
}
19
Source : VariableExpressionTests.cs
with MIT License
from Jamiras
with MIT License
from Jamiras
[Test]
public void TestGetDependencies()
{
var expr = new VariableExpression("variable1");
var dependencies = new HashSet<string>();
((INestedExpressions)expr).GetDependencies(dependencies);
replacedert.That(dependencies.Count, Is.EqualTo(1));
replacedert.That(dependencies.Contains("variable1"));
}
19
Source : AlgorithmsUtilities_Tests.cs
with MIT License
from karamba3d
with MIT License
from karamba3d
[Test]
public void AABBTreeRayIntersection_FindIntersection_NoValidIntersection()
{
Vector3 projVect = new Vector3(0, 0, -1);
var mesh = MakeMesh();
var aabbTree = MakeAABBTree(mesh);
var inputPoints = new Point3(1, 0.6, 0.6); //point outside mesh
Intersection intersection = ShellSecAlgorithms.RayAABBTreeIntersections(inputPoints, projVect, aabbTree);
replacedert.That(intersection is null);
}
19
Source : MaskBoundariesTest.cs
with MIT License
from microsoft
with MIT License
from microsoft
private void CheckNoBoundaryPointsInImage(Volume3D<byte> inputImage, bool withEdges)
{
var outputImage = inputImage.MaskBoundaries(withEdges);
replacedert.That(Array.TrueForAll(outputImage.Array, x => x == 0));
}
19
Source : MaskBoundariesTest.cs
with MIT License
from microsoft
with MIT License
from microsoft
private void CheckBoundaryIsAsExpected(Volume3D<byte> inputImage, bool withEdges, Point3D[] boundaryPoints)
{
var outputImage = inputImage.MaskBoundaries(withEdges);
var preplaceded = false;
for (int x = 0; x < inputImage.DimX; ++x)
{
for (int y = 0; y < inputImage.DimY; ++y)
{
for (int z = 0; z < inputImage.DimZ; ++z)
{
var point = new Point3D(x, y, z);
var isBoundary = (int)outputImage[x, y, z] == 1;
if (isBoundary && boundaryPoints.Contains(point))
{
preplaceded = true;
}
else if (isBoundary && !(withEdges && inputImage.IsEdgeVoxel(x, y, z)))
{
replacedert.Fail($"{x},{y},{z} should not be a boundary voxel");
}
}
}
}
replacedert.That(preplaceded);
}
See More Examples