Пример #1
0
        public void CanRoundtripFilledOutNestedTypesWithoutRecursion2()
        {
            using (var client = new RecursiveTypesAPI(new Uri("http://localhost:3000"), new MirroringHandler()))
            {
                var parentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "1"
                };

                var childProduct1 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId     = "11",
                    ParentProduct = parentProduct
                };

                var product = client.Post("123", "rg1", "1.0", childProduct1);
                Assert.Equal(childProduct1.ProductId, product.ProductId);
                Assert.Equal(childProduct1.ParentProduct.ProductId, product.ParentProduct.ProductId);
            }
        }
Пример #2
0
        public void CanRoundtripFilledOutNestedTypesWithoutRecursion()
        {
            using (var client = new RecursiveTypesAPI(new Uri("http://localhost:3000"), new MirroringHandler()))
            {

                var grandParentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "0"
                };

                var parentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "1"
                };

                var childProduct1 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "11",
                };

                var childProduct2 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "12",
                };

                parentProduct.ParentProduct = grandParentProduct;
                parentProduct.InnerProducts = new List<Fixtures.MirrorRecursiveTypes.Models.Product>();
                parentProduct.InnerProducts.Add(childProduct1);
                parentProduct.InnerProducts.Add(childProduct2);

                var product = client.Post("123", "rg1", "1.0", parentProduct);
                Assert.Equal(parentProduct.ParentProduct.ProductId, product.ParentProduct.ProductId);
                Assert.Equal(parentProduct.ProductId, product.ProductId);
                Assert.Equal(parentProduct.InnerProducts.Count, product.InnerProducts.Count);
                Assert.Equal(parentProduct.InnerProducts[0].ProductId, product.InnerProducts[0].ProductId);
                Assert.Equal(parentProduct.InnerProducts[1].ProductId, product.InnerProducts[1].ProductId);
            }
        }
Пример #3
0
        public void CanRoundtripFilledOutNestedTypesWithoutRecursion()
        {
            using (var client = new RecursiveTypesAPI(new Uri("http://localhost:3000"), new MirroringHandler()))
            {
                var grandParentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "0"
                };

                var parentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "1"
                };

                var childProduct1 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "11",
                };

                var childProduct2 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "12",
                };

                parentProduct.ParentProduct = grandParentProduct;
                parentProduct.InnerProducts = new List <Fixtures.MirrorRecursiveTypes.Models.Product>();
                parentProduct.InnerProducts.Add(childProduct1);
                parentProduct.InnerProducts.Add(childProduct2);

                var product = client.Post("123", "rg1", "1.0", parentProduct);
                Assert.Equal(parentProduct.ParentProduct.ProductId, product.ParentProduct.ProductId);
                Assert.Equal(parentProduct.ProductId, product.ProductId);
                Assert.Equal(parentProduct.InnerProducts.Count, product.InnerProducts.Count);
                Assert.Equal(parentProduct.InnerProducts[0].ProductId, product.InnerProducts[0].ProductId);
                Assert.Equal(parentProduct.InnerProducts[1].ProductId, product.InnerProducts[1].ProductId);
            }
        }
Пример #4
0
        public void CanRoundtripFilledOutNestedTypesWithoutRecursion2()
        {
            using (var client = new RecursiveTypesAPI(new Uri("http://localhost:3000"), new MirroringHandler()))
            {

                var parentProduct = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "1"
                };

                var childProduct1 = new Fixtures.MirrorRecursiveTypes.Models.Product
                {
                    ProductId = "11",
                    ParentProduct = parentProduct
                };

                var product = client.Post("123", "rg1", "1.0", childProduct1);
                Assert.Equal(childProduct1.ProductId, product.ProductId);
                Assert.Equal(childProduct1.ParentProduct.ProductId, product.ParentProduct.ProductId);
            }
        }