Ejemplo n.º 1
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiCustomerCommunicationServerModelMapper();
            var model  = new ApiCustomerCommunicationServerResponseModel();

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

            response.Should().NotBeNull();
            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Notes.Should().Be("A");
        }
Ejemplo n.º 2
0
        public void CreatePatch()
        {
            var mapper = new ApiCustomerCommunicationServerModelMapper();
            var model  = new ApiCustomerCommunicationServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Notes.Should().Be("A");
        }
Ejemplo n.º 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 ApiCustomerCommunicationServerModelMapper();
            ApplicationDbContext          context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ICustomerCommunicationService service             = testServer.Host.Services.GetService(typeof(ICustomerCommunicationService)) as ICustomerCommunicationService;
            ApiCustomerCommunicationServerResponseModel model = await service.Get(1);

            ApiCustomerCommunicationClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B");

            UpdateResponse <ApiCustomerCommunicationClientResponseModel> updateResponse = await client.CustomerCommunicationUpdateAsync(model.Id, request);

            context.Entry(context.Set <CustomerCommunication>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <CustomerCommunication>().ToList()[0].CustomerId.Should().Be(1);
            context.Set <CustomerCommunication>().ToList()[0].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <CustomerCommunication>().ToList()[0].EmployeeId.Should().Be(1);
            context.Set <CustomerCommunication>().ToList()[0].Notes.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.CustomerId.Should().Be(1);
            updateResponse.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.EmployeeId.Should().Be(1);
            updateResponse.Record.Notes.Should().Be("B");
        }