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;

            ICustomerService service = testServer.Host.Services.GetService(typeof(ICustomerService)) as ICustomerService;
            var model = new ApiCustomerServerRequestModel();

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

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

            ActionResponse deleteResult = await client.CustomerDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiCustomerServerModelMapper();
            var model  = new ApiCustomerServerRequestModel();

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

            response.Should().NotBeNull();
            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
        }
Esempio n. 3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <ICustomerService, ICustomerRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Customer>(null));
            var service = new CustomerService(mock.LoggerMock.Object,
                                              mock.MediatorMock.Object,
                                              mock.RepositoryMock.Object,
                                              mock.ModelValidatorMockFactory.CustomerModelValidatorMock.Object,
                                              mock.DALMapperMockFactory.DALCustomerMapperMock);

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

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