Example #1
0
        public void CanRoundTripSequences()
        {
            SwaggerSpecRunner.RunTests(
                SwaggerPath("swagger-mirror-sequences.json"), ExpectedPath("Mirror.Sequences"));
            using (var sequenceClient = MirrorTestHelpers.CreateSequenceClient())
            {
                var testList = new List <int?> {
                    1, 1, 2, 3, 5, 8, 13, 21
                };
                var intList = sequenceClient.AddPetStyles(testList);
                MirrorTestHelpers.ValidateList(testList, intList, (s, t) => Assert.Equal(s, t));

                var petList = new List <Pet>
                {
                    new Pet
                    {
                        Id     = 1,
                        Name   = "fluffy",
                        Tag    = "rabbit",
                        Styles = new List <PetStyle> {
                            new PetStyle {
                                Name = "cute"
                            }, new PetStyle {
                                Name = "cuddly"
                            }
                        }
                    },
                    new Pet
                    {
                        Id     = 2,
                        Name   = "rex",
                        Tag    = "dog",
                        Styles = new List <PetStyle> {
                            new PetStyle {
                                Name = "friendly"
                            }, new PetStyle {
                                Name = "loyal"
                            }
                        }
                    },
                    new Pet
                    {
                        Id     = 10111,
                        Name   = "Tabby",
                        Tag    = "cat",
                        Styles = new List <PetStyle> {
                            new PetStyle {
                                Name = "independent"
                            }
                        }
                    }
                };

                var actualPets = sequenceClient.AddPet(petList);
                MirrorTestHelpers.ValidateList(petList, actualPets, MirrorTestHelpers.ValidatePet);
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public void UrlIsCorrectWhenBaseUriContainsSegment()
        {
            var product = MirrorTestHelpers.GenerateProduct();

            using (var content = new StringContent(""))
                using (var message = new HttpResponseMessage {
                    Content = content
                })
                    using (var handler = new RecordedDelegatingHandler(message))
                        using (var client = MirrorTestHelpers.CreateDataClient(handler))
                        {
                            client.BaseUri = new Uri("http://somesite/segment1/");
                            client.PutProduct("200", product);
                            Assert.Equal("http://somesite/segment1/datatypes", handler.Uri.AbsoluteUri);
                        }
        }