Пример #1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            ICallService service = testServer.Host.Services.GetService(typeof(ICallService)) as ICallService;
            var          model   = new ApiCallServerRequestModel();

            model.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);
            CreateResponse <ApiCallServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.CallDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiCallServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
Пример #2
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <ICallService, ICallRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Call>(null));
            var service = new CallService(mock.LoggerMock.Object,
                                          mock.MediatorMock.Object,
                                          mock.RepositoryMock.Object,
                                          mock.ModelValidatorMockFactory.CallModelValidatorMock.Object,
                                          mock.DALMapperMockFactory.DALCallMapperMock,
                                          mock.DALMapperMockFactory.DALCallAssignmentMapperMock,
                                          mock.DALMapperMockFactory.DALNoteMapperMock);

            ApiCallServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Пример #3
0
        public void MapServerRequestToResponse()
        {
            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);
            ApiCallServerResponseModel response = mapper.MapServerRequestToResponse(1, 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);
        }