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 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 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"}
            //                }}.
        }
示例#4
0
        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").
        }
示例#5
0
        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 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
        }
示例#7
0
        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 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 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 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 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 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 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").
        }
示例#16
0
        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"}
            //                }}.
        }