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;

            IEmployeeService service = testServer.Host.Services.GetService(typeof(IEmployeeService)) as IEmployeeService;
            var model = new ApiEmployeeServerRequestModel();

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

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

            ActionResponse deleteResult = await client.EmployeeDeleteAsync(2);

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

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

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

            response.Should().NotBeNull();
            response.FirstName.Should().Be("A");
            response.IsSalesPerson.Should().Be(true);
            response.IsShipper.Should().Be(true);
            response.LastName.Should().Be("A");
        }
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IEmployeeService, IEmployeeRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Employee>(null));
            var service = new EmployeeService(mock.LoggerMock.Object,
                                              mock.MediatorMock.Object,
                                              mock.RepositoryMock.Object,
                                              mock.ModelValidatorMockFactory.EmployeeModelValidatorMock.Object,
                                              mock.DALMapperMockFactory.DALEmployeeMapperMock,
                                              mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock,
                                              mock.DALMapperMockFactory.DALPipelineStepMapperMock,
                                              mock.DALMapperMockFactory.DALPipelineStepNoteMapperMock);

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

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