예제 #1
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiStudioServerModelMapper();
            var model  = new ApiStudioServerResponseModel();

            model.SetProperties(1, "A", "A", "A", "A", "A", "A", "A");
            ApiStudioServerRequestModel response = mapper.MapServerResponseToRequest(model);

            response.Should().NotBeNull();
            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.City.Should().Be("A");
            response.Name.Should().Be("A");
            response.Province.Should().Be("A");
            response.Website.Should().Be("A");
            response.Zip.Should().Be("A");
        }
예제 #2
0
        public void CreatePatch()
        {
            var mapper = new ApiStudioServerModelMapper();
            var model  = new ApiStudioServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.Address1.Should().Be("A");
            response.Address2.Should().Be("A");
            response.City.Should().Be("A");
            response.Name.Should().Be("A");
            response.Province.Should().Be("A");
            response.Website.Should().Be("A");
            response.Zip.Should().Be("A");
        }
예제 #3
0
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiStudioServerModelMapper();
            ApplicationDbContext         context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IStudioService               service = testServer.Host.Services.GetService(typeof(IStudioService)) as IStudioService;
            ApiStudioServerResponseModel model   = await service.Get(1);

            ApiStudioClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", "B", "B", "B", "B", "B", "B");

            UpdateResponse <ApiStudioClientResponseModel> updateResponse = await client.StudioUpdateAsync(model.Id, request);

            context.Entry(context.Set <Studio>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Studio>().ToList()[0].Address1.Should().Be("B");
            context.Set <Studio>().ToList()[0].Address2.Should().Be("B");
            context.Set <Studio>().ToList()[0].City.Should().Be("B");
            context.Set <Studio>().ToList()[0].Name.Should().Be("B");
            context.Set <Studio>().ToList()[0].Province.Should().Be("B");
            context.Set <Studio>().ToList()[0].Website.Should().Be("B");
            context.Set <Studio>().ToList()[0].Zip.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Address1.Should().Be("B");
            updateResponse.Record.Address2.Should().Be("B");
            updateResponse.Record.City.Should().Be("B");
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.Province.Should().Be("B");
            updateResponse.Record.Website.Should().Be("B");
            updateResponse.Record.Zip.Should().Be("B");
        }