public void listContains_predicate_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); //comment line below to fail test player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message //Assert.That(player1.Party.Any(p => p.Name == "Testor The Mighty Barbarian"), Is.True); //--> Expected: True But was: False //FluentAssertions syntax player1.Party.Should().Contain(p => p.Name == "Testor The Mighty Barbarian"); //-->Result Message: Collection { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 100 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // should have an item matching(p.Name == "Testor The Mighty Barbarian"). }
public void objectGraph_EquivalentTo_test() { var player1 = new Player("Joe Tester"); var p1_teamMember1 = new TestorTheBarbarian() { Health = 99 }; var p1_teamMember2 = new MasterCodo() { Health = 100 }; player1.Party.Add(p1_teamMember1); player1.Party.Add(p1_teamMember2); var player2 = new Player("Joe Tester"); var p2_teamMember1 = new TestorTheBarbarian() { Health = 99 }; var p2_teamMember2 = new MasterCodo() { Health = 100 }; player2.Party.Add(p2_teamMember1); player2.Party.Add(p2_teamMember2); //to fail test uncomment //p1_teamMember2.Health = 0; //p2_teamMember1.AddAttack("Bug Be Gone"); //Nunit does not have an equivalent would need separate asserts //FluentAssertions syntax player1.ShouldBeEquivalentTo(player2); // --> Result Message: // Expected member Party[0].Attacks to be a collection with 2 item(s), but found 1. // Expected member Party[1].Health to be 100, but found 0. // With configuration: // - Use declared types and members // - Compare enums by value // - Match member by name(or throw) // - Be strict about the order of items in byte arrays }
public void listAll_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //to fail test //teamMember2.Health = 0; //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.All(p => p.Health > 0), Is.True); //FluentAssertions syntax player1.Party.Should().OnlyContain(p => p.Health > 0); //-->Result Message: Expected collection to contain only items matching(p.Health > 0), but { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 0 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // do (es)not match. }
public void stringStartWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.StartsWith(expectedText, testor.Name); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringStarting(expectedText)); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().StartWith(expectedText); //--> Result Message: Expected string to start with "Conan", but "Testor The Mighty Barbarian" differs near "Tes"(index 0). //with optional description testor.Name.Should().StartWith(expectedText, because: "we're looking to rent the movie"); //--> Result Message: Expected string to start with "Conan" because we're looking to rent the movie, but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). }
public void listEmpty_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); //uncomment line below to fail test //player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.IsEmpty(player1.Party); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //NUnit Constraint model Assert.That(player1.Party, Is.Empty); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //FluentAssertions syntax player1.Party.Should().BeEmpty(); //-->Result Message: Expected collection to be empty, but found { // TestorTheBarbarianDemo.TestorTheBarbarian //{ // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 100 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // } // }. }
public void stringComparison_Test() { var testor = new TestorTheBarbarian(); var expectedName = "Testor The Mighty Barbarian"; //to fail test //expectedName = "testor the mighty barbarian"; //Nunit classic model Assert.AreEqual(expectedName, testor.Name); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName)); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().Be(expectedName); //--> Result Message: Expected string to be "testor the mighty barbarian", but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). //with optional description testor.Name.Should().Be(expectedName, because: "this is case sensitive"); //--> Result Message: Expected string to be "testor the mighty barbarian" because this is case sensitive, but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). }
public void stringComparison_Test() { var testor = new TestorTheBarbarian(); var expectedName = "Testor The Mighty Barbarian"; //to fail test //expectedName = "testor the mighty barbarian"; //Nunit classic model Assert.AreEqual(expectedName, testor.Name); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName)); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().Be(expectedName); //--> Result Message: Expected string to be "testor the mighty barbarian", but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). //with optional description testor.Name.Should().Be(expectedName, because: "this is case sensitive"); //--> Result Message: Expected string to be "testor the mighty barbarian" because this is case sensitive, but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). }
public void stringComparison_ignoreCase_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model var expectedName = "testor the mighty barbarian"; //to fail test //expectedName = "testor"; StringAssert.AreEqualIgnoringCase(expectedName, testor.Name); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName).IgnoreCase); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().BeEquivalentTo(expectedName); //--> Result Message: Expected string to be equivalent to "testor" with a length of 6, but // "Testor The Mighty Barbarian" has a length of 27. //with optional description testor.Name.Should().BeEquivalentTo(expectedName, because: "we're ignoring case"); //--> Result Message: Expected string to be equivalent to "testor" with a length of 6 because we're ignoring case, but // "Testor The Mighty Barbarian" has a length of 27. }
public void listAll_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //to fail test //teamMember2.Health = 0; //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.All(p => p.Health > 0), Is.True); //FluentAssertions syntax player1.Party.Should().OnlyContain(p => p.Health > 0); //-->Result Message: Expected collection to contain only items matching(p.Health > 0), but { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 0 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // do (es)not match. }
public void stringComparison_ignoreCase_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model var expectedName = "testor the mighty barbarian"; //to fail test //expectedName = "testor"; StringAssert.AreEqualIgnoringCase(expectedName, testor.Name); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName).IgnoreCase); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().BeEquivalentTo(expectedName); //--> Result Message: Expected string to be equivalent to "testor" with a length of 6, but // "Testor The Mighty Barbarian" has a length of 27. //with optional description testor.Name.Should().BeEquivalentTo(expectedName, because: "we're ignoring case"); //--> Result Message: Expected string to be equivalent to "testor" with a length of 6 because we're ignoring case, but // "Testor The Mighty Barbarian" has a length of 27. }
public void listAscendingOrder_predicate_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian() { Health=99}; var teamMember2 = new MasterCodo() { Health = 100 }; player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //to fail test //teamMember2.Health = 0; //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message //Assert.That(player1.Party.All(p => p.Health > 0), Is.True); //FluentAssertions syntax player1.Party.Should().BeInAscendingOrder(p => p.Health); //-->Result Message: Expected collection { // TestorTheBarbarianDemo.TestorTheBarbarian // { // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 99 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // }, // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 0 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // to be ordered by "Health" and result in { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 0 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // }, // TestorTheBarbarianDemo.TestorTheBarbarian // { // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 99 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // }}. }
public void timedResult_Test() { var testor = new TestorTheBarbarian(); //set sleep to >1000 to fail test const int sleepyTime = 500; //nunit closest option MaxTime attribute on the test method. testor.ExecutionTimeOf(z => z.Rest(sleepyTime)).ShouldNotExceed(1.Seconds()); //-->Execution of (z.Rest(1500)) should not exceed 1s, but it required 1.698s }
public void timedResult_Test() { var testor = new TestorTheBarbarian(); //set sleep to >1000 to fail test const int sleepyTime = 500; //nunit closest option MaxTime attribute on the test method. testor.ExecutionTimeOf(z => z.Rest(sleepyTime)).ShouldNotExceed(1.Seconds()); //-->Execution of (z.Rest(1500)) should not exceed 1s, but it required 1.698s }
public void stringDoesNotContain_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model StringAssert.DoesNotContain("Bugra", testor.Name); //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringContaining("Bugra")); //shouldly syntax testor.Name.ShouldNotContain("Bugra"); }
public void timedResult_Test() { var testor = new TestorTheBarbarian(); //set sleep to >1000 to fail test var sleepyTime = 500; //nunit closest option MaxTime attribute on the test method. Should.CompleteIn( () => testor.Rest(sleepyTime), TimeSpan.FromSeconds(1) ); //--> Task should complete in 00:00:01 but did not }
public void timedResult_Test() { var testor = new TestorTheBarbarian(); //set sleep to >1000 to fail test var sleepyTime = 500; //nunit closest option MaxTime attribute on the test method. Should.CompleteIn( () => testor.Rest(sleepyTime), TimeSpan.FromSeconds(1) ); //--> Task should complete in 00:00:01 but did not }
public void objectGraph_EquivalentTo_test() { var player1 = new Player("Joe Tester"); var p1_teamMember1 = new TestorTheBarbarian() { Health = 99 }; var p1_teamMember2 = new MasterCodo() { Health = 100 }; player1.Party.Add(p1_teamMember1); player1.Party.Add(p1_teamMember2); var player2 = new Player("Joe Tester"); var p2_teamMember1 = new TestorTheBarbarian() { Health = 99 }; var p2_teamMember2 = new MasterCodo() { Health = 100 }; player2.Party.Add(p2_teamMember1); player2.Party.Add(p2_teamMember2); //to fail test uncomment //p1_teamMember2.Health = 0; //p2_teamMember1.AddAttack("Bug Be Gone"); //Nunit does not have an equivalent would need separate asserts //FluentAssertions syntax player1.ShouldBeEquivalentTo(player2); // --> Result Message: // Expected member Party[0].Attacks to be a collection with 2 item(s), but found 1. // Expected member Party[1].Health to be 100, but found 0. // With configuration: // - Use declared types and members // - Compare enums by value // - Match member by name(or throw) // - Be strict about the order of items in byte arrays }
public void listContains_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember2); //comment line below to fail test player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.Contains(player1.Party, teamMember1); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //NUnit Constraint model Assert.That(player1.Party, Has.Member(teamMember1)); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //FluentAssertions syntax player1.Party.Should().Contain(teamMember1); //-->Result Message: Expected collection { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 100 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // to contain // TestorTheBarbarianDemo.TestorTheBarbarian // { // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 100 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // }. }
public void stringNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //to fail test //testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNullOrEmpty(testor.ActiveWeapon); // --> Expected: null or empty string But was: "Fists of Fury" //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Null.Or.Empty); // --> Expected: null or empty string But was: "Fists of Fury" //shouldly syntax testor.ActiveWeapon.ShouldBeNullOrEmpty(); // --> testor.ActiveWeapon should be null or empty }
public void stringContains_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.Contains(expectedText, testor.Name); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringContaining(expectedText)); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldContain(expectedText); //--> testor.Name should contain "Conan" but does not }
public void stringNotNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //comment line below to fail test testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNotNullOrEmpty(testor.ActiveWeapon); // --> Expected: not null or empty string But was: null //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty); // --> Expected: not null or empty string But was: null //shouldly syntax testor.ActiveWeapon.ShouldNotBeNullOrEmpty(); // --> testor.ActiveWeapon should not be null or empty }
public void stringComparison_ignoreCase_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model var expectedName = "testor the mighty barbarian"; //to fail test // expectedName = "testor"; StringAssert.AreEqualIgnoringCase(expectedName, testor.Name); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName).IgnoreCase); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldBe(expectedName, Case.Insensitive); //-->testor.Name should be "testor", but was: "Testor The Mighty Barbarian" }
public void stringComparison_Test() { var testor = new TestorTheBarbarian(); var expectedName = "Testor The Mighty Barbarian"; //to fail test //expectedName = "testor the mighty barbarian"; //Nunit classic model Assert.AreEqual(expectedName, testor.Name); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName)); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldBe(expectedName); //-->testor.Name should be "testor the mighty barbarian" but was "Testor The Mighty Barbarian" }
public void stringEndWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Barbarian"; //to fail test //expectedText = "Gentle"; //Nunit Classic Model StringAssert.EndsWith(expectedText, testor.Name); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringEnding(expectedText)); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldEndWith(expectedText); //--> testor.Name should end with "Gentle" but was "Testor The Mighty Barbarian" }
public void stringComparison_Test() { var testor = new TestorTheBarbarian(); var expectedName = "Testor The Mighty Barbarian"; //to fail test //expectedName = "testor the mighty barbarian"; //Nunit classic model Assert.AreEqual(expectedName, testor.Name); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName)); //-->Expected: "testor the mighty barbarian" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldBe(expectedName); //-->testor.Name should be "testor the mighty barbarian" but was "Testor The Mighty Barbarian" }
public void stringContains_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.Contains(expectedText, testor.Name); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringContaining(expectedText)); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldContain(expectedText); //--> testor.Name should contain "Conan" but does not }
public void stringComparison_ignoreCase_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model var expectedName = "testor the mighty barbarian"; //to fail test // expectedName = "testor"; StringAssert.AreEqualIgnoringCase(expectedName, testor.Name); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.EqualTo(expectedName).IgnoreCase); //-->Expected: "testor", ignoring case But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldBe(expectedName, Case.Insensitive); //-->testor.Name should be "testor", but was: "Testor The Mighty Barbarian" }
public void listContains_predicate_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); //comment line below to fail test player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.Any(p => p.Name == "Testor The Mighty Barbarian"), Is.True); //--> Expected: True But was: False //shouldly syntax player1.Party.ShouldContain(p => p.Name == "Testor The Mighty Barbarian"); //-->player1.Party should contain an element satisfying the condition (p.Name=="Testor The Mighty Barbarian") // but does not }
public void listAll_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //to fail test //teamMember2.Health = 0; //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.All(p => p.Health > 0), Is.True); //shouldly syntax player1.Party.ShouldAllBe(p=>p.Health >0); //-->player1.Party should satisfy the condition (p.Health>0) but // [TestorTheBarbarianDemo.MasterCodo] but do not }
public void listContains_predicate_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); //comment line below to fail test player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.Any(p => p.Name == "Testor The Mighty Barbarian"), Is.True); //--> Expected: True But was: False //shouldly syntax player1.Party.ShouldContain(p=>p.Name=="Testor The Mighty Barbarian"); //-->player1.Party should contain an element satisfying the condition (p.Name=="Testor The Mighty Barbarian") // but does not }
public void listAll_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //to fail test //teamMember2.Health = 0; //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message Assert.That(player1.Party.All(p => p.Health > 0), Is.True); //shouldly syntax player1.Party.ShouldAllBe(p => p.Health > 0); //-->player1.Party should satisfy the condition (p.Health>0) but // [TestorTheBarbarianDemo.MasterCodo] but do not }
public void stringStartWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.StartsWith(expectedText, testor.Name); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringStarting(expectedText)); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldStartWith(expectedText); //--> testor.Name should start with "Conan" but was "Testor The Mighty Barbarian" }
public void listEmpty_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); //uncomment line below to fail test //player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.IsEmpty(player1.Party); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //NUnit Constraint model Assert.That(player1.Party, Is.Empty); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //shouldly syntax player1.Party.ShouldBeEmpty(); //-->player1.Party should be empty but had 1 item and it was [TestorTheBarbarianDemo.TestorTheBarbarian] }
public void typeValidation_Test() { iCharacter testor = new TestorTheBarbarian(); //to fail test //testor = new MasterCodo(); //Nunit classic model Assert.IsInstanceOf <TestorTheBarbarian>(testor); //--> Result Message: Expected: instance of < TestorTheBarbarianDemo.TestorTheBarbarian > // But was: < TestorTheBarbarianDemo.MasterCodo > //NUnit Constraint model Assert.That(testor, Is.InstanceOf <TestorTheBarbarian>()); //--> Result Message: Expected: instance of < TestorTheBarbarianDemo.TestorTheBarbarian > // But was: < TestorTheBarbarianDemo.MasterCodo > //FluentAssertions syntax testor.Should().BeOfType <TestorTheBarbarian>(); //-->Result Message: Expected type to be TestorTheBarbarianDemo.TestorTheBarbarian, // but found TestorTheBarbarianDemo.MasterCodo. }
public void listContains_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember2); //comment line below to fail test player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.Contains(player1.Party, teamMember1); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //NUnit Constraint model Assert.That(player1.Party, Has.Member(teamMember1)); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //shouldly syntax player1.Party.ShouldContain(teamMember1); //-->player1.Party should contain TestorTheBarbarianDemo.TestorTheBarbarian but does not }
public void typeValidation_Test() { iCharacter testor = new TestorTheBarbarian(); //to fail test //testor = new MasterCodo(); //Nunit classic model Assert.IsInstanceOf<TestorTheBarbarian>(testor); //--> Result Message: Expected: instance of < TestorTheBarbarianDemo.TestorTheBarbarian > // But was: < TestorTheBarbarianDemo.MasterCodo > //NUnit Constraint model Assert.That(testor, Is.InstanceOf<TestorTheBarbarian>()); //--> Result Message: Expected: instance of < TestorTheBarbarianDemo.TestorTheBarbarian > // But was: < TestorTheBarbarianDemo.MasterCodo > //FluentAssertions syntax testor.Should().BeOfType<TestorTheBarbarian>(); //-->Result Message: Expected type to be TestorTheBarbarianDemo.TestorTheBarbarian, // but found TestorTheBarbarianDemo.MasterCodo. }
public void stringNotEndWith_Test() { var testor = new TestorTheBarbarian(); //comment above and uncomment below to fail test //var testor = new Enemy() { Name = "Bugra" }; //Nunit Classic Model StringAssert.DoesNotEndWith("ra", testor.Name); // -->Expected: not String ending with "do" But was: "Master Codo" //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringEnding("ra")); // -->Expected: not String ending with "do" But was: "Master Codo" //FluentAssertions syntax testor.Name.Should().NotEndWith("ra"); // --> Result Message: Expected string "Bugra" not to end with "ra". testor.Name.Should().NotEndWith("do", because: "object is a testor"); // --> Result Message: Expected string "Bugra" not to end with "ra" because object is a testor. }
public void stringDoesNotContain_Test() { var testor = new TestorTheBarbarian(); // to fail test comment above and uncomment below //var testor = new Enemy() { Name = "Bugra" }; //Nunit Classic Model StringAssert.DoesNotContain("Bugra", testor.Name); // --> Expected: not String containing "Bugra" But was: "Bugra" //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringContaining("Bugra")); // --> Expected: not String containing "Bugra" But was: "Bugra" //FluentAssertions syntax testor.Name.Should().NotContain("Bugra"); // --> Result Message: Did not expect string "Bugra" to contain "Bugra". //optional description testor.Name.Should().NotContain("Bugra", because: "its name is Testor"); // --> Result Message: Did not expect string "Bugra" to contain "Bugra" because its name is Testor. }
public void multipleAsserts_Test() { var testor = new TestorTheBarbarian(); //change either or both value(s) below to fail test var expectedText = "testor"; var expectedHealth = 100; //Nunit does not support this in 2.X but similar functionality is in discussion for v3 (Assert.All) //shouldly syntax testor.ShouldSatisfyAllConditions( () => testor.Name.ShouldContain(expectedText), () => testor.Health.ShouldBe(expectedHealth) ); //--> testor should satisfy all the conditions specified, but does not. // The following errors were found... //-------------- - Error 1-------------- - // testor.Name should contain "bugra" but does not //-------------- - Error 2-------------- - // testor.Health should be 10 but was 100 //-------------------------------------- - }
public void stringContains_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.Contains(expectedText, testor.Name); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringContaining(expectedText)); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().Contain(expectedText); //--> Result Message: Expected string "Testor The Mighty Barbarian" to contain "Conan". //optional desctiption testor.Name.Should().Contain(expectedText,because:"we are looking to rent the movie"); //--> Result Message: Expected string "Testor The Mighty Barbarian" to contain "Conan" because we are looking to rent the movie. }
public void stringNotStartWith_Test() { var testor = new TestorTheBarbarian(); //comment above and uncomment below to fail test //var testor = new Enemy() { Name = "Bugra" }; //Nunit Classic Model StringAssert.DoesNotStartWith("Bug", testor.Name); // --> Expected: not String starting with "Bug" But was: "Bugra" //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringStarting("Bug")); // --> Expected: not String starting with "Bug" But was: "Bugra" //FluentAssertions syntax testor.Name.Should().NotStartWith("Bug"); // --> Result Message: Expected string that does not start with "Bug", but found "Bugra". //with optional description testor.Name.Should().NotStartWith("Bug", because: "testor isn't Bugra"); // --> Result Message: Expected string that does not start with "Bug" because testor isn't Bugra, but found "Bugra". }
public void multipleAsserts_Test() { var testor = new TestorTheBarbarian(); //change either or both value(s) below to fail test var expectedText = "testor"; var expectedHealth = 100; //Nunit does not support this in 2.X but similar functionality is in discussion for v3 (Assert.All) //shouldly syntax testor.ShouldSatisfyAllConditions( () => testor.Name.ShouldContain(expectedText), () => testor.Health.ShouldBe(expectedHealth) ); //--> testor should satisfy all the conditions specified, but does not. // The following errors were found... //-------------- - Error 1-------------- - // testor.Name should contain "bugra" but does not //-------------- - Error 2-------------- - // testor.Health should be 10 but was 100 //-------------------------------------- - }
public void stringNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //to fail test //testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNullOrEmpty(testor.ActiveWeapon); // --> Expected: null or empty string But was: "Fists of Fury" //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Null.Or.Empty); // --> Expected: null or empty string But was: "Fists of Fury" //FluentAssertions syntax testor.ActiveWeapon.Should().BeNullOrEmpty(); // --> Result Message: Expected string to be <null> or empty, but found "Fists of Fury". // with optional description testor.ActiveWeapon.Should().BeNullOrEmpty(because: "no weapon has been equipped"); // --> Result Message: Expected string to be <null> or empty because no weapon has been equipped, but found "Fists of Fury". }
public void listContains_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember2); //comment line below to fail test player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.Contains(player1.Party, teamMember1); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //NUnit Constraint model Assert.That(player1.Party, Has.Member(teamMember1)); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //shouldly syntax player1.Party.ShouldContain(teamMember1); //-->player1.Party should contain TestorTheBarbarianDemo.TestorTheBarbarian but does not }
public void stringContains_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.Contains(expectedText, testor.Name); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringContaining(expectedText)); //-->Expected: String Containing "Conan" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().Contain(expectedText); //--> Result Message: Expected string "Testor The Mighty Barbarian" to contain "Conan". //optional desctiption testor.Name.Should().Contain(expectedText, because: "we are looking to rent the movie"); //--> Result Message: Expected string "Testor The Mighty Barbarian" to contain "Conan" because we are looking to rent the movie. }
public void stringEndWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Barbarian"; //to fail test //expectedText = "Gentle"; //Nunit Classic Model StringAssert.EndsWith(expectedText, testor.Name); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringEnding(expectedText)); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().EndWith(expectedText); //--> Result Message: Expected string "Testor The Mighty Barbarian" to end with "Gentle". //with optional description testor.Name.Should().EndWith(expectedText, because: "appearances can be deceiving"); //--> Result Message: Expected string "Testor The Mighty Barbarian" to end with "Gentle" because appearances can be deceiving. }
public void listEmpty_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); //uncomment line below to fail test //player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.IsEmpty(player1.Party); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //NUnit Constraint model Assert.That(player1.Party, Is.Empty); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //shouldly syntax player1.Party.ShouldBeEmpty(); //-->player1.Party should be empty but had 1 item and it was [TestorTheBarbarianDemo.TestorTheBarbarian] }
public void stringNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //to fail test //testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNullOrEmpty(testor.ActiveWeapon); // --> Expected: null or empty string But was: "Fists of Fury" //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Null.Or.Empty); // --> Expected: null or empty string But was: "Fists of Fury" //FluentAssertions syntax testor.ActiveWeapon.Should().BeNullOrEmpty(); // --> Result Message: Expected string to be <null> or empty, but found "Fists of Fury". // with optional description testor.ActiveWeapon.Should().BeNullOrEmpty(because:"no weapon has been equipped"); // --> Result Message: Expected string to be <null> or empty because no weapon has been equipped, but found "Fists of Fury". }
public void stringNotEndWith_Test() { var testor = new TestorTheBarbarian(); //comment above and uncomment below to fail test //var testor = new Enemy() { Name = "Bugra" }; //Nunit Classic Model StringAssert.DoesNotEndWith("ra", testor.Name); // -->Expected: not String ending with "do" But was: "Master Codo" //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringEnding("ra")); // -->Expected: not String ending with "do" But was: "Master Codo" //FluentAssertions syntax testor.Name.Should().NotEndWith("ra"); // --> Result Message: Expected string "Bugra" not to end with "ra". testor.Name.Should().NotEndWith("do", because:"object is a testor"); // --> Result Message: Expected string "Bugra" not to end with "ra" because object is a testor. }
public void listContains_predicate_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); //comment line below to fail test player1.Party.Add(teamMember1); player1.Party.Add(teamMember2); //Nunit does not have an equivalent either separate asserts or a boolean which // will loose detail and have a generic message //Assert.That(player1.Party.Any(p => p.Name == "Testor The Mighty Barbarian"), Is.True); //--> Expected: True But was: False //FluentAssertions syntax player1.Party.Should().Contain(p => p.Name == "Testor The Mighty Barbarian"); //-->Result Message: Collection { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 100 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // should have an item matching(p.Name == "Testor The Mighty Barbarian"). }
public void listContains_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); var teamMember2 = new MasterCodo(); player1.Party.Add(teamMember2); //comment line below to fail test player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.Contains(player1.Party, teamMember1); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //NUnit Constraint model Assert.That(player1.Party, Has.Member(teamMember1)); //--> Expected: collection containing <TestorTheBarbarianDemo.TestorTheBarbarian> But was: < <TestorTheBarbarianDemo.MasterCodo > > //FluentAssertions syntax player1.Party.Should().Contain(teamMember1); //-->Result Message: Expected collection { // TestorTheBarbarianDemo.MasterCodo // { // ActiveWeapon = < null > // Attacks = { "Sling"} // BattleCry = "" // Health = 100 // Name = "Master Codo" // Weapons = { "Fiery Fingers"} // } // } // to contain // TestorTheBarbarianDemo.TestorTheBarbarian // { // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 100 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // }. }
public void stringStartWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.StartsWith(expectedText, testor.Name); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringStarting(expectedText)); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().StartWith(expectedText); //--> Result Message: Expected string to start with "Conan", but "Testor The Mighty Barbarian" differs near "Tes"(index 0). //with optional description testor.Name.Should().StartWith(expectedText,because:"we're looking to rent the movie"); //--> Result Message: Expected string to start with "Conan" because we're looking to rent the movie, but // "Testor The Mighty Barbarian" differs near "Tes"(index 0). }
public void stringEndWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Barbarian"; //to fail test //expectedText = "Gentle"; //Nunit Classic Model StringAssert.EndsWith(expectedText, testor.Name); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringEnding(expectedText)); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldEndWith(expectedText); //--> testor.Name should end with "Gentle" but was "Testor The Mighty Barbarian" }
public void stringNotNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //comment line below to fail test testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNotNullOrEmpty(testor.ActiveWeapon); // --> Expected: not null or empty string But was: null //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty); // --> Expected: not null or empty string But was: null //shouldly syntax testor.ActiveWeapon.ShouldNotBeNullOrEmpty(); // --> testor.ActiveWeapon should not be null or empty }
public void listEmpty_test() { var player1 = new Player("Joe Tester"); var teamMember1 = new TestorTheBarbarian(); //uncomment line below to fail test //player1.Party.Add(teamMember1); //Nunit classic model CollectionAssert.IsEmpty(player1.Party); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //NUnit Constraint model Assert.That(player1.Party, Is.Empty); //--> Expected: <empty> But was: < <TestorTheBarbarianDemo.TestorTheBarbarian > > //FluentAssertions syntax player1.Party.Should().BeEmpty(); //-->Result Message: Expected collection to be empty, but found { // TestorTheBarbarianDemo.TestorTheBarbarian //{ // ActiveWeapon = < null > // Attacks = { "Clobber"} // BattleCry = "" // Health = 100 // Name = "Testor The Mighty Barbarian" // Weapons = { "Fists Of Fury"} // } // }. }
public void stringDoesNotContain_Test() { var testor = new TestorTheBarbarian(); //Nunit Classic Model StringAssert.DoesNotContain("Bugra", testor.Name); //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringContaining("Bugra")); //shouldly syntax testor.Name.ShouldNotContain("Bugra"); }
public void stringNotStartWith_Test() { var testor = new TestorTheBarbarian(); //comment above and uncomment below to fail test //var testor = new Enemy() { Name = "Bugra" }; //Nunit Classic Model StringAssert.DoesNotStartWith("Bug", testor.Name); // --> Expected: not String starting with "Bug" But was: "Bugra" //NUnit Constraint model Assert.That(testor.Name, Is.Not.StringStarting("Bug")); // --> Expected: not String starting with "Bug" But was: "Bugra" //FluentAssertions syntax testor.Name.Should().NotStartWith("Bug"); // --> Result Message: Expected string that does not start with "Bug", but found "Bugra". //with optional description testor.Name.Should().NotStartWith("Bug", because:"testor isn't Bugra"); // --> Result Message: Expected string that does not start with "Bug" because testor isn't Bugra, but found "Bugra". }
public void stringStartWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Testor"; //to fail test //expectedText = "Conan"; //Nunit Classic Model StringAssert.StartsWith(expectedText, testor.Name); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringStarting(expectedText)); //--> Expected: String starting with "Conan" But was: "Testor The Mighty Barbarian" //shouldly syntax testor.Name.ShouldStartWith(expectedText); //--> testor.Name should start with "Conan" but was "Testor The Mighty Barbarian" }
public void stringEndWith_Test() { var testor = new TestorTheBarbarian(); var expectedText = "Barbarian"; //to fail test //expectedText = "Gentle"; //Nunit Classic Model StringAssert.EndsWith(expectedText, testor.Name); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //NUnit Constraint model Assert.That(testor.Name, Is.StringEnding(expectedText)); //--> Expected: String ending with "Gentle" But was: "Testor The Mighty Barbarian" //FluentAssertions syntax testor.Name.Should().EndWith(expectedText); //--> Result Message: Expected string "Testor The Mighty Barbarian" to end with "Gentle". //with optional description testor.Name.Should().EndWith(expectedText, because: "appearances can be deceiving"); //--> Result Message: Expected string "Testor The Mighty Barbarian" to end with "Gentle" because appearances can be deceiving. }
public void stringNullOrEmpty_Test() { var testor = new TestorTheBarbarian(); //to fail test //testor.EquipWeapon("Fists of Fury"); //Nunit Classic Model Assert.IsNullOrEmpty(testor.ActiveWeapon); // --> Expected: null or empty string But was: "Fists of Fury" //NUnit Constraint model Assert.That(testor.ActiveWeapon, Is.Null.Or.Empty); // --> Expected: null or empty string But was: "Fists of Fury" //shouldly syntax testor.ActiveWeapon.ShouldBeNullOrEmpty(); // --> testor.ActiveWeapon should be null or empty }