protected static void AssertOwnedPerson(OwnedPerson expected, OwnedPerson actual)
        {
            if (expected == null && actual == null)
            {
                return;
            }

            Assert.Equal(expected.Id, actual.Id);
            AssertAddress(expected.PersonAddress, actual.PersonAddress);

            Assert.Equal(expected.Orders.Count, actual.Orders.Count);
            foreach (var element in expected.Orders.OrderBy(ee => ee.Id).Zip(actual.Orders.OrderBy(aa => aa.Id), (e, a) => new { e, a }))
            {
                Assert.Equal(element.e.Id, element.a.Id);
                Assert.Equal(element.e.Client.Id, element.a.Client.Id);
            }

            if (expected is Branch expectedBranch)
            {
                AssertAddress(expectedBranch.PersonAddress, ((Branch)actual).PersonAddress);
            }

            if (expected is LeafA expectedLeafA)
            {
                AssertAddress(expectedLeafA.LeafAAddress, ((LeafA)actual).LeafAAddress);
            }

            if (expected is LeafB expectedLeafB)
            {
                AssertAddress(expectedLeafB.LeafBAddress, ((LeafB)actual).LeafBAddress);
            }
        }
            private static IReadOnlyList <OwnedPerson> CreateOwnedPeople()
            {
                var ownedPerson1 = new OwnedPerson
                {
                    Id            = 1,
                    PersonAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "USA", PlanetId = 1
                        }
                    },
                };

                var ownedPerson2 = new Branch
                {
                    Id            = 2,
                    PersonAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "USA", PlanetId = 1
                        }
                    },
                    BranchAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "Canada", PlanetId = 1
                        }
                    },
                };

                var ownedPerson3 = new LeafA
                {
                    Id            = 3,
                    PersonAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "USA", PlanetId = 1
                        }
                    },
                    BranchAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "Canada", PlanetId = 1
                        }
                    },
                    LeafAAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "Mexico", PlanetId = 1
                        }
                    },
                };

                var ownedPerson4 = new LeafB
                {
                    Id            = 4,
                    PersonAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "USA", PlanetId = 1
                        }
                    },
                    LeafBAddress = new OwnedAddress {
                        Country = new OwnedCountry {
                            Name = "Panama", PlanetId = 1
                        }
                    },
                };

                ownedPerson1.Orders = new List <Order> {
                    new Order {
                        Id = -11, Client = ownedPerson1
                    }, new Order {
                        Id = -10, Client = ownedPerson1
                    }
                };
                ownedPerson2.Orders = new List <Order> {
                    new Order {
                        Id = -20, Client = ownedPerson2
                    }
                };
                ownedPerson3.Orders = new List <Order> {
                    new Order {
                        Id = -30, Client = ownedPerson3
                    }
                };
                ownedPerson4.Orders = new List <Order> {
                    new Order {
                        Id = -40, Client = ownedPerson4
                    }
                };

                return(new List <OwnedPerson> {
                    ownedPerson1, ownedPerson2, ownedPerson3, ownedPerson4
                });
            }
Exemple #3
0
 private static int Map(OwnedPerson p) => p.PersonAddress.Country.PlanetId;