Exemplo n.º 1
0
        public void CanSerializeAndDeserializePrimitiveTypes()
        {
            // first regen the spec
            SwaggerSpecRunner.RunTests(
                SwaggerPath("swagger-mirror-primitives.json"), ExpectedPath("Mirror.Primitives"));

            //Now run mocked tests using the client
            var product = MirrorTestHelpers.GenerateProduct();

            using (var client = MirrorTestHelpers.CreateDataClient())
            {
                var response = client.PutProduct("200", product);
                MirrorTestHelpers.ValidateProduct(product, response);
            }
        }
Exemplo n.º 2
0
        public void CanRoundtripPolymorphicTypes()
        {
            SwaggerSpecRunner.RunTests(
                SwaggerPath("swagger-mirror-polymorphic.json"),
                ExpectedPath("Mirror.Polymorphic"));

            var pets = new[]
            {
                new Animal {
                    Description = "Pet Only", Id = "1"
                },
                new BaseCat {
                    Description = "Base Cat", Id = "2", Color = "blue"
                },
                new Doggy {
                    Description = "Doggy", Id = "3", Name = "Rex"
                },
                new Horsey {
                    Description = "Horsey", Id = "4", Breed = "Paint"
                },
                new HimalayanCat {
                    Description = "Himalayn", Id = "1", Color = "blue", HairLength = 17, Length = 22
                },
                new BurmeseCat {
                    Description = "Himalayn", Id = "1", Color = "blue", Length = 22, NickName = 76
                },
                new SiameseCat {
                    Description = "Himalayn", Id = "1", Color = "blue", Length = 22
                }
            };

            foreach (var pet in pets)
            {
                SendAndComparePolymorphicObjects(pet);
            }
        }