示例#1
0
        public void All_NormalInput_NormalResult()
        {
            //arrange
            Initialize("people.json");
            var expected = new Owner[]
            {
                new Owner
                {
                    Name   = "Bob",
                    Gender = Male,
                    Age    = 23,
                    Pets   = new Pet[]
                    {
                        new Pet
                        {
                            Name    = "Garfield",
                            PetType = Cat
                        },
                        new Pet
                        {
                            Name    = "Fido",
                            PetType = Dog
                        }
                    }
                },
                new Owner
                {
                    Name   = "Jennifer",
                    Gender = Female,
                    Age    = 18,
                    Pets   = new Pet[]
                    {
                        new Pet
                        {
                            Name    = "Garfield",
                            PetType = Cat
                        }
                    }
                },
                new Owner
                {
                    Name   = "Steve",
                    Gender = Male,
                    Age    = 45,
                },
                new Owner
                {
                    Name   = "Fred",
                    Gender = Male,
                    Age    = 40,
                    Pets   = new Pet[]
                    {
                        new Pet
                        {
                            Name    = "Tom",
                            PetType = Cat
                        },
                        new Pet
                        {
                            Name    = "Max",
                            PetType = Cat,
                        },
                        new Pet
                        {
                            Name    = "Sam",
                            PetType = Dog
                        },
                        new Pet
                        {
                            Name    = "Jim",
                            PetType = Cat
                        }
                    }
                },
                new Owner
                {
                    Name   = "Samantha",
                    Gender = Female,
                    Age    = 40,
                    Pets   = new Pet[]
                    {
                        new Pet
                        {
                            Name    = "Tabby",
                            PetType = Cat
                        }
                    }
                },
                new Owner
                {
                    Name   = "Alice",
                    Gender = Female,
                    Age    = 64,
                    Pets   = new Pet[]
                    {
                        new Pet
                        {
                            Name    = "Simba",
                            PetType = Cat
                        },
                        new Pet
                        {
                            Name    = "Nemo",
                            PetType = Fish
                        }
                    }
                }
            };

            //act
            var result = _targetClass.All().Result;

            _listener.Stop();

            var resultArray = result.ToArray();

            // assert

            CollectionAssert.AreEqual(expected, resultArray, _ownerComparer);
        }