Example #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;

            ICallPersonService service = testServer.Host.Services.GetService(typeof(ICallPersonService)) as ICallPersonService;
            var model = new ApiCallPersonServerRequestModel();

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

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

            ActionResponse deleteResult = await client.CallPersonDeleteAsync(2);

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

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

            model.SetProperties("A", 1, 1);
            ApiCallPersonServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Note.Should().Be("A");
            response.PersonId.Should().Be(1);
            response.PersonTypeId.Should().Be(1);
        }
Example #3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <ICallPersonService, ICallPersonRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <CallPerson>(null));
            var service = new CallPersonService(mock.LoggerMock.Object,
                                                mock.MediatorMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.CallPersonModelValidatorMock.Object,
                                                mock.DALMapperMockFactory.DALCallPersonMapperMock);

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

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