public async System.Threading.Tasks.Task GetClientsWithTheirNamesAndTheirYardsWithAddressesForSupplierTest() { var j = JinagaTest.Create(); var supplier1 = await j.Fact(new Supplier("---Sup01PubKey---")); var supplier2 = await j.Fact(new Supplier("---Sup02PubKey---")); var supplier3 = await j.Fact(new Supplier("---Sup03PubKey---")); var client1_S1 = await j.Fact(new Client(supplier1, DateTime.Now.AddSeconds(-1.0))); var client2_S1 = await j.Fact(new Client(supplier1, DateTime.Now)); var client1_S2 = await j.Fact(new Client(supplier2, DateTime.Now)); var client1_S3 = await j.Fact(new Client(supplier3, DateTime.Now)); var name1A_C1_S1 = await j.Fact(new ClientName(client1_S1, "N1A_C1_S1", new ClientName[] { })); var name1B_C1_S1 = await j.Fact(new ClientName(client1_S1, "N1B_C1_S1", new ClientName[] { })); var name2_C1_S1 = await j.Fact(new ClientName(client1_S1, "N2_C1_S1", new ClientName[] { name1A_C1_S1, name1B_C1_S1 })); var name1_C2_S1 = await j.Fact(new ClientName(client2_S1, "N1_C2_S1", new ClientName[] { })); var name2A_C2_S1 = await j.Fact(new ClientName(client2_S1, "N2A_C2_S1", new ClientName[] { name1_C2_S1 })); var name2B_C2_S1 = await j.Fact(new ClientName(client2_S1, "N2B_C2_S1", new ClientName[] { name1_C2_S1 })); var name1_C1_S2 = await j.Fact(new ClientName(client1_S2, "N1_C1_S2", new ClientName[] { })); var name1_C1_S3 = await j.Fact(new ClientName(client1_S3, "N1_C1_S3", new ClientName[] { })); var yard1_C1_S1 = await j.Fact(new Yard(client1_S1, DateTime.Now.AddSeconds(-1.0))); var yard2_C1_S1 = await j.Fact(new Yard(client1_S1, DateTime.Now)); var yard1_C2_S1 = await j.Fact(new Yard(client2_S1, DateTime.Now)); var yard1_C1_S2 = await j.Fact(new Yard(client1_S2, DateTime.Now)); var address1_Y1_C1_S1 = await j.Fact(new YardAddress(yard1_C1_S1, "Name_Y1_C1_S1", "Gate is locked. Call owner (Tel: 0612345678) for code.", "TestStreet", "12C", "123456ABC", "TestCity", "France", new YardAddress[] { })); var address2_Y1_C1_S1 = await j.Fact(new YardAddress(yard1_C1_S1, "Name_Y1_C1_S1", "Gate is locked. Call owner (Tel: 0612345678) for code.", "TestStreet", "12B", "123456ABC", "TestCity", "France", new YardAddress[] { address1_Y1_C1_S1 })); var address1_Y2_C1_S1 = await j.Fact(new YardAddress(yard2_C1_S1, "Name_Y2_C1_S1", "Remark for address1_Y2_C1_S1", "Corneel Franckstraat", "24", "2100", "Deurne", "België", new YardAddress[] { })); var address2A_Y2_C1_S1 = await j.Fact(new YardAddress(yard2_C1_S1, "Name_Y2_C1_S1", "Remark for address2A_Y2_C1_S1", "Brusselstraat", "15", "2018", "Antwerpen", "België", new YardAddress[] { address1_Y2_C1_S1 })); var address2B_Y2_C1_S1 = await j.Fact(new YardAddress(yard2_C1_S1, "Name_Y2_C1_S1", "Remark for address2B_Y2_C1_S1", "Brusselstraat", "51", "2018", "Antwerpen", "Belgium", new YardAddress[] { address1_Y2_C1_S1 })); var address1_Y1_C2_S1 = await j.Fact(new YardAddress(yard1_C2_S1, "Name_Y1_C2_S1", "Remark for address1_Y1_C2_S1", "TestStreet", "99", "1234A", "Paris", "France", new YardAddress[] { })); var address1_Y1_C1_S2 = await j.Fact(new YardAddress(yard1_C1_S2, "Name_Y1_C1_S2", "Remark for address1_Y1_C1_S2", "AnotherStreet", "547B", "66740", "Place", "Belgique", new YardAddress[] { })); ImmutableList <ClientData> ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier1 = await j.Query(supplier1, Specifications.ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier()); var flattened = Transforms.FlattenClientYardData(ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier1); flattened.Should().BeEquivalentTo( new[] { new { client = client1_S1, // clientNames = new[] {name2_C1_S1}, clientName = name2_C1_S1.name, yard = yard1_C1_S1, yardAddress = Transforms.AddressToString(address2_Y1_C1_S1) // yardAddresses = new[] { address2_Y1_C1_S1} }, new { client = client1_S1, clientName = name2_C1_S1.name, // clientNames = new[] {name2_C1_S1}, yard = yard2_C1_S1, yardAddress = Transforms.AddressToString(address2A_Y2_C1_S1) // yardAddresses = new[] { address2A_Y2_C1_S1, address2B_Y2_C1_S1 } }, new { client = client2_S1, clientName = name2A_C2_S1.name, // clientNames = new[] {name2A_C2_S1, name2B_C2_S1}, yard = yard1_C2_S1, yardAddress = Transforms.AddressToString(address1_Y1_C2_S1) // yardAddresses = new[] { address1_Y1_C2_S1 } } } ); // ImmutableList<ClientData> ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier2 = await j.Query(supplier2, Specifications.ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier()); // ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier2.Should().BeEquivalentTo( // new[] { // new { // client = client1_S2, // clientNames = new[] {name1_C1_S2}, // yard = yard1_C1_S2, // yardAddresses = new[] { address1_Y1_C1_S2 } // } // } // ); // ImmutableList<ClientData> ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier3 = await j.Query(supplier3, Specifications.ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier()); // ClientsWithTheirNamesAndTheirYardsWithAddressesForSupplier3.Should().BeEquivalentTo( // new[] { // new { // client = client1_S3, // clientNames = new[] {name1_C1_S3}, // yard = (Yard)null, // yardAddresses = Array.Empty<object>() // } // } // ); }