Exemplo n.º 1
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiPetModelMapper();
            var model  = new ApiPetResponseModel();

            model.SetProperties(1, 1, 1, "A", 1);
            ApiPetRequestModel response = mapper.MapResponseToRequest(model);

            response.BreedId.Should().Be(1);
            response.ClientId.Should().Be(1);
            response.Name.Should().Be("A");
            response.Weight.Should().Be(1);
        }
Exemplo n.º 2
0
        public async void TestUpdate()
        {
            var model = await this.CreateRecord();

            ApiPetModelMapper mapper = new ApiPetModelMapper();

            UpdateResponse <ApiPetResponseModel> updateResponse = await this.Client.PetUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();

            await this.Cleanup();
        }
Exemplo n.º 3
0
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiPetModelMapper();
            var model  = new ApiPetClientResponseModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A", 1, 1m);
            ApiPetClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.AcquiredDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.BreedId.Should().Be(1);
            response.Description.Should().Be("A");
            response.PenId.Should().Be(1);
            response.Price.Should().Be(1m);
        }
Exemplo n.º 4
0
        public void CreatePatch()
        {
            var mapper = new ApiPetModelMapper();
            var model  = new ApiPetRequestModel();

            model.SetProperties(1, 1, "A", 1);

            JsonPatchDocument <ApiPetRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiPetRequestModel();

            patch.ApplyTo(response);
            response.BreedId.Should().Be(1);
            response.ClientId.Should().Be(1);
            response.Name.Should().Be("A");
            response.Weight.Should().Be(1);
        }
Exemplo n.º 5
0
        public void CreatePatch()
        {
            var mapper = new ApiPetModelMapper();
            var model  = new ApiPetRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A", 1, 1m, 1);

            JsonPatchDocument <ApiPetRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiPetRequestModel();

            patch.ApplyTo(response);
            response.AcquiredDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.BreedId.Should().Be(1);
            response.Description.Should().Be("A");
            response.PenId.Should().Be(1);
            response.Price.Should().Be(1m);
            response.SpeciesId.Should().Be(1);
        }
Exemplo n.º 6
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiPetResponseModel model = await client.PetGetAsync(1);

            ApiPetModelMapper mapper = new ApiPetModelMapper();

            UpdateResponse <ApiPetResponseModel> updateResponse = await client.PetUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }