Esempio n. 1
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 ApiCallServerModelMapper();
            ApplicationDbContext       context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ICallService               service = testServer.Host.Services.GetService(typeof(ICallService)) as ICallService;
            ApiCallServerResponseModel model   = await service.Get(1);

            ApiCallClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

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

            UpdateResponse <ApiCallClientResponseModel> updateResponse = await client.CallUpdateAsync(model.Id, request);

            context.Entry(context.Set <Call>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Call>().ToList()[0].AddressId.Should().Be(1);
            context.Set <Call>().ToList()[0].CallDispositionId.Should().Be(1);
            context.Set <Call>().ToList()[0].CallStatusId.Should().Be(1);
            context.Set <Call>().ToList()[0].CallString.Should().Be("B");
            context.Set <Call>().ToList()[0].CallTypeId.Should().Be(1);
            context.Set <Call>().ToList()[0].DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[0].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[0].DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Call>().ToList()[0].QuickCallNumber.Should().Be(2);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.AddressId.Should().Be(1);
            updateResponse.Record.CallDispositionId.Should().Be(1);
            updateResponse.Record.CallStatusId.Should().Be(1);
            updateResponse.Record.CallString.Should().Be("B");
            updateResponse.Record.CallTypeId.Should().Be(1);
            updateResponse.Record.DateCleared.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.DateDispatched.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.QuickCallNumber.Should().Be(2);
        }
Esempio n. 2
0
        public void MapServerResponseToRequest()
        {
            var mapper = new ApiCallServerModelMapper();
            var model  = new ApiCallServerResponseModel();

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

            response.Should().NotBeNull();
            response.AddressId.Should().Be(1);
            response.CallDispositionId.Should().Be(1);
            response.CallStatusId.Should().Be(1);
            response.CallString.Should().Be("A");
            response.CallTypeId.Should().Be(1);
            response.DateCleared.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DateDispatched.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.QuickCallNumber.Should().Be(1);
        }
Esempio n. 3
0
        public void CreatePatch()
        {
            var mapper = new ApiCallServerModelMapper();
            var model  = new ApiCallServerRequestModel();

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

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

            patch.ApplyTo(response);
            response.AddressId.Should().Be(1);
            response.CallDispositionId.Should().Be(1);
            response.CallStatusId.Should().Be(1);
            response.CallString.Should().Be("A");
            response.CallTypeId.Should().Be(1);
            response.DateCleared.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DateDispatched.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.QuickCallNumber.Should().Be(1);
        }