public void Test_Creation_Of_List_Handles_Differences_Correctly() { var mockIo = Substitute.For <IIO>(); mockIo.DirectoryExist(Arg.Any <string>()).Returns(true); // Irrelevant at this point mockIo.GetFiles("a", "*", true).Returns(new List <string> { @"a\a_only.txt", @"a\sub\common.txt", }); mockIo.GetFiles("b", "*", true).Returns(new List <string> { @"b\b_only.txt", @"b\sub\common.txt", }); var list = new FileGatherer(mockIo, "a", "b").CreateFilelist().ToList(); Assert.That(list, Has.Count.EqualTo(3), "Expect three entries found"); Assert.That(list.FirstOrDefault(l => l.CommonName.Contains("a_only")), Has.Property(nameof(CompareEntry.PathB)).Null, "a_only must exist only on the item 1 side"); Assert.That(list.FirstOrDefault(l => l.CommonName.Contains("b_only")), Has.Property(nameof(CompareEntry.PathA)).Null, "b_only must exist only on the item 2 side"); Assert.That(list.FirstOrDefault(l => l.PathA != null && l.PathB != null), Has.Property(nameof(CompareEntry.CommonName)).Contains("common"), "b_only must exist only on the item 2 side"); }
public void ShouldHaveDenominationProperty() { Assert.That(_sut, Has.Property("Denomination")); }
public void ShouldHaveCurrencyProperty() { Assert.That(_sut, Has.Property("Currency")); }
public PropertyTest_ConstraintFollows() { ParseTree = "<property X <greaterthan 5>>"; StaticSyntax = Has.Property("X").GreaterThan(5); BuilderSyntax = Builder().Property("X").GreaterThan(5); }
public void ExistenceTest() { Assert.That(ints, Has.Property("Length")); Assert.That(ints, Has.Length); }
public void ShouldHaveField_Trending() { var @group = new Group(); Assert.That(@group, Has.Property("Trending")); }
public PropertyExistsTest() { ParseTree = "<propertyexists X>"; StaticSyntax = Has.Property("X"); BuilderSyntax = Builder().Property("X"); }
public static void PropertyValue_ShadowingPropertyOfDifferentType(string propertyName, bool shouldUseShadowingProperty) { var instance = new DerivedClassWithoutProperty(); Assert.That(instance, Has.Property(propertyName).EqualTo(shouldUseShadowingProperty ? 2 : 1)); }
public static void NUnitExplicitBoolPropertyIsNotProvidedForThirdPartyRunnersInNonExplicitTestCases(string testName) { var testCase = GetSampleTestCase(testName); Assert.That(testCase, Has.Property("Properties").With.None.With.Property("Id").EqualTo("NUnit.Explicit")); }
public void Ctor() { Assert.That(new CredentialNotFoundException("foo"), Has.Property("Message").EqualTo("Credentials not found for server 'foo'")); }
public static void PropertyExists_ShadowingPropertyOfDifferentType(string propertyName) { var instance = new DerivedClassWithoutProperty(); Assert.That(instance, Has.Property(propertyName)); }
public void ShouldHaveField_GroupsCanPost() { var comments = new Comments(); Assert.That(comments, Has.Property("GroupsCanPost")); }
public void RuntimeFrameworkIsSetForSubpackages() { //Runtime Service verifies that requested frameworks are available, therefore this test can only currently be run on platforms with both CLR v2 and v4 available Assume.That(new RuntimeFramework(RuntimeType.Net, new Version("2.0.50727")), Has.Property(nameof(RuntimeFramework.IsAvailable)).True); Assume.That(new RuntimeFramework(RuntimeType.Net, new Version("4.0.30319")), Has.Property(nameof(RuntimeFramework.IsAvailable)).True); var topLevelPackage = new TestPackage(new [] { "a.dll", "b.dll" }); var net20Package = topLevelPackage.SubPackages[0]; net20Package.Settings.Add(InternalEnginePackageSettings.ImageRuntimeVersion, new Version("2.0.50727")); var net40Package = topLevelPackage.SubPackages[1]; net40Package.Settings.Add(InternalEnginePackageSettings.ImageRuntimeVersion, new Version("4.0.30319")); _runtimeService.SelectRuntimeFramework(topLevelPackage); Assert.Multiple(() => { Assert.That(net20Package.Settings[EnginePackageSettings.RuntimeFramework], Is.EqualTo("net-2.0")); Assert.That(net40Package.Settings[EnginePackageSettings.RuntimeFramework], Is.EqualTo("net-4.0")); Assert.That(topLevelPackage.Settings[EnginePackageSettings.RuntimeFramework], Is.EqualTo("net-4.0")); }); }
public void PropertyTests() { string[] array = { "abc", "bca", "xyz", "qrs" }; string[] array2 = { "a", "ab", "abc" }; ArrayList list = new ArrayList(array); // Not available using the classic syntax // Constraint Syntax Assert.That(list, Has.Property("Count")); Assert.That(list, Has.No.Property("Length")); Assert.That("Hello", Has.Length.EqualTo(5)); Assert.That("Hello", Has.Length.LessThan(10)); Assert.That("Hello", Has.Property("Length").EqualTo(5)); Assert.That("Hello", Has.Property("Length").GreaterThan(3)); Assert.That(array, Has.Property("Length").EqualTo(4)); Assert.That(array, Has.Length.EqualTo(4)); Assert.That(array, Has.Property("Length").LessThan(10)); Assert.That(array, Has.All.Property("Length").EqualTo(3)); Assert.That(array, Has.All.Length.EqualTo(3)); Assert.That(array, Is.All.Length.EqualTo(3)); Assert.That(array, Has.All.Property("Length").EqualTo(3)); Assert.That(array, Is.All.Property("Length").EqualTo(3)); Assert.That(array2, Has.Some.Property("Length").EqualTo(2)); Assert.That(array2, Has.Some.Length.EqualTo(2)); Assert.That(array2, Has.Some.Property("Length").GreaterThan(2)); Assert.That(array2, Is.Not.Property("Length").EqualTo(4)); Assert.That(array2, Is.Not.Length.EqualTo(4)); Assert.That(array2, Has.No.Property("Length").GreaterThan(3)); Assert.That(List.Map(array2).Property("Length"), Is.EqualTo(new int[] { 1, 2, 3 })); Assert.That(List.Map(array2).Property("Length"), Is.EquivalentTo(new int[] { 3, 2, 1 })); Assert.That(List.Map(array2).Property("Length"), Is.SubsetOf(new int[] { 1, 2, 3, 4, 5 })); Assert.That(List.Map(array2).Property("Length"), Is.Unique); Assert.That(list, Has.Count.EqualTo(4)); // Inherited syntax Expect(list, Property("Count")); Expect(list, Not.Property("Nada")); Expect("Hello", Length.EqualTo(5)); Expect("Hello", Property("Length").EqualTo(5)); Expect("Hello", Property("Length").GreaterThan(0)); Expect(array, Property("Length").EqualTo(4)); Expect(array, Length.EqualTo(4)); Expect(array, Property("Length").LessThan(10)); Expect(array, All.Length.EqualTo(3)); Expect(array, All.Property("Length").EqualTo(3)); Expect(array2, Some.Property("Length").EqualTo(2)); Expect(array2, Some.Length.EqualTo(2)); Expect(array2, Some.Property("Length").GreaterThan(2)); Expect(array2, None.Property("Length").EqualTo(4)); Expect(array2, None.Length.EqualTo(4)); Expect(array2, None.Property("Length").GreaterThan(3)); Expect(Map(array2).Property("Length"), EqualTo(new int[] { 1, 2, 3 })); Expect(Map(array2).Property("Length"), EquivalentTo(new int[] { 3, 2, 1 })); Expect(Map(array2).Property("Length"), SubsetOf(new int[] { 1, 2, 3, 4, 5 })); Expect(Map(array2).Property("Length"), Unique); Expect(list, Count.EqualTo(4)); }
/// <summary> /// Returns a new PropertyConstraintExpression, which will either /// test for the existence of the named property on the object /// being tested or apply any following constraint to that property. /// </summary> public ResolvableConstraintExpression Property(string name) { return(Has.Property(name)); }
public void SetUp() { ParseTree = "<propertyexists X>"; StaticSyntax = Has.Property("X"); BuilderSyntax = Builder().Property("X"); }
public void ApartmentStateUnknownIsNotRunnable() { var testSuite = TestBuilder.MakeFixture(typeof(ApartmentDataRequiresThreadAttribute)); Assert.That(testSuite, Has.Property(nameof(TestSuite.RunState)).EqualTo(RunState.NotRunnable)); }
public void SetUp() { ParseTree = "<and <propertyexists X> <equal 7>>"; StaticSyntax = Has.Property("X").And.EqualTo(7); BuilderSyntax = Builder().Property("X").And.EqualTo(7); }
public void DeserializeSupersetKey_QueryFile3_List() { int testNr = 3; // Create an instance of the XmlSerializer specifying type and namespace. TestSuiteXml ts = DeserializeSample(); Assert.That(ts.Tests[testNr].Constraints[0], Is.TypeOf <SupersetOfXml>()); Assert.That(((SupersetOfXml)ts.Tests[testNr].Constraints[0]).ColumnsDef, Has.Count.EqualTo(2)); Assert.That(((SupersetOfXml)ts.Tests[testNr].Constraints[0]).ColumnsDef[0], Has.Property("Index").EqualTo(3)); Assert.That(((SupersetOfXml)ts.Tests[testNr].Constraints[0]).ColumnsDef[0], Has.Property("Tolerance").EqualTo("10")); Assert.That(((SupersetOfXml)ts.Tests[testNr].Constraints[0]).ColumnsDef[1], Has.Property("Index").EqualTo(4)); Assert.That(((SupersetOfXml)ts.Tests[testNr].Constraints[0]).ColumnsDef[1], Has.Property("Type").EqualTo(ColumnType.Boolean)); }
public void SetUp() { ParseTree = "<property X <not <greaterthan 5>>>"; StaticSyntax = Has.Property("X").Not.GreaterThan(5); BuilderSyntax = Builder().Property("X").Not.GreaterThan(5); }
public PropertyExistsTest_AndFollows() { ParseTree = "<and <propertyexists X> <equal 7>>"; StaticSyntax = Has.Property("X").And.EqualTo(7); BuilderSyntax = Builder().Property("X").And.EqualTo(7); }
public void DataFieldsContainCorrectProperties(string expected) { Assert.That(_missionDesignService.missionDesignDataList[0], Has.Property(expected)); }
public PropertyTest_NotFollows() { ParseTree = "<property X <not <greaterthan 5>>>"; StaticSyntax = Has.Property("X").Not.GreaterThan(5); BuilderSyntax = Builder().Property("X").Not.GreaterThan(5); }
public void ParsePath([Random(0, int.MaxValue, 20, Distinct = true)] int seed) { // Probably a bit more complex then desired, but it does make something... var rand = new Random(seed); var pathCount = rand.Next(2, 9); var pathBuilder = new StringBuilder(); var expectedPath = new Tuple <ParserPathElementType, object> [pathCount]; for (int i = 0; i < pathCount; i++) { var type = PathElementTypes[rand.Next(0, PathElementTypes.Length)]; object value; if (type.Item2 == ParserPathElementType.IndexField) { // Int value = rand.Next(); } else { // String var bytes = new byte[16]; rand.NextBytes(bytes); value = new Guid(bytes).ToString(); } pathBuilder.AppendFormat("/{0}{1}", type.Item1, value); expectedPath[i] = new Tuple <ParserPathElementType, object>(type.Item2, value); } var appendType = rand.Next(0, 100) < 50; var typeInfo = PathFieldTypes[rand.Next(0, PathFieldTypes.Length)]; if (appendType) { pathBuilder.AppendFormat("&{0}", typeInfo.Item1); } else { typeInfo = PathFieldTypes[0]; // Get the string type, since it's default } // For debugging Console.WriteLine(pathBuilder); // Actual tests var path = ParserUtil.ParsePath(pathBuilder.ToString()); Assert.That(path, Is.Not.Null.And.Length.EqualTo(pathCount)); for (int i = 0; i < pathCount; i++) { var typeExpression = Has.Property("Type").EqualTo(expectedPath[i].Item1); var valueExpression = typeExpression.And.Property(expectedPath[i].Item1 == ParserPathElementType.IndexField ? "IndexValue" : "StringValue").EqualTo(expectedPath[i].Item2); NUnit.Framework.Constraints.IResolveConstraint finalExpression; if (i == (pathCount - 1)) { finalExpression = valueExpression.And.Property("FieldType").EqualTo(typeInfo.Item2); } else { finalExpression = valueExpression.And.Property("FieldType").EqualTo(ParserPathElementFieldType.NotAValue); } Assert.That(path[i], finalExpression); } }
public void SeparateConstraintTest() { Assert.That(ints, Has.Property("Length").EqualTo(3)); Assert.That(ints, Has.Length.EqualTo(3)); }
public void ShouldHaveExtraPower() { object enemy = sut_EF.Create(true); Assert.That(enemy, Has.Property("ExtraPower")); }
public void ShouldHaveQuantityProperty() { Assert.That(_sut, Has.Property("Quantity")); }
public void SizeDoesNotMatchInfo_CheckInput() { _testContext.Differs.Add(new Differ() { Id = 1, LeftInput = "AAAAAA==", RightInput = "AAA=" }); _testContext.SaveChanges(); var result = _sut.CheckInput("1"); Assert.That(result, Has.Property("ResultType").EqualTo("SizeDoesNotMatch") & Has.Property("Diffs").EqualTo(null)); }
public void ShouldHaveTotalProperty() { Assert.That(_sut, Has.Property("Total")); }
public void SetUp() { ParseTree = "<after 1000 <property X <equal 10>>>"; StaticSyntax = Has.Property("X").EqualTo(10).After(1000); BuilderSyntax = Builder().Property("X").EqualTo(10).After(1000); }