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;

            IOfficerCapabilitiesService service = testServer.Host.Services.GetService(typeof(IOfficerCapabilitiesService)) as IOfficerCapabilitiesService;
            var model = new ApiOfficerCapabilitiesServerRequestModel();

            model.SetProperties(1, 1);
            CreateResponse <ApiOfficerCapabilitiesServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.OfficerCapabilitiesDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Example #2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiOfficerCapabilitiesServerModelMapper();
            var model  = new ApiOfficerCapabilitiesServerRequestModel();

            model.SetProperties(1, 1);
            ApiOfficerCapabilitiesServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.CapabilityId.Should().Be(1);
            response.OfficerId.Should().Be(1);
        }
Example #3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IOfficerCapabilitiesService, IOfficerCapabilitiesRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <OfficerCapabilities>(null));
            var service = new OfficerCapabilitiesService(mock.LoggerMock.Object,
                                                         mock.MediatorMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.OfficerCapabilitiesModelValidatorMock.Object,
                                                         mock.DALMapperMockFactory.DALOfficerCapabilitiesMapperMock);

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

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }