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; ICustomerCommunicationService service = testServer.Host.Services.GetService(typeof(ICustomerCommunicationService)) as ICustomerCommunicationService; var model = new ApiCustomerCommunicationServerRequestModel(); model.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B"); CreateResponse <ApiCustomerCommunicationServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.CustomerCommunicationDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiCustomerCommunicationServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public CustomerCommunicationController(ICustomerCommunicationService iCustomerCommunicationService, IUnitOfWork unitOfWork, ICustomerService iCustomerService) { _iCustomerCommunicationService = iCustomerCommunicationService; _unitOfWork = unitOfWork; _iCustomerService = iCustomerService; }
public CustomerCommunicationController( ApiSettings settings, ILogger <CustomerCommunicationController> logger, ITransactionCoordinator transactionCoordinator, ICustomerCommunicationService customerCommunicationService, IApiCustomerCommunicationServerModelMapper customerCommunicationModelMapper ) : base(settings, logger, transactionCoordinator) { this.CustomerCommunicationService = customerCommunicationService; this.CustomerCommunicationModelMapper = customerCommunicationModelMapper; this.BulkInsertLimit = 250; this.MaxLimit = 1000; this.DefaultLimit = 250; }
public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); var mapper = new ApiCustomerCommunicationServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ICustomerCommunicationService service = testServer.Host.Services.GetService(typeof(ICustomerCommunicationService)) as ICustomerCommunicationService; ApiCustomerCommunicationServerResponseModel model = await service.Get(1); ApiCustomerCommunicationClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B"); UpdateResponse <ApiCustomerCommunicationClientResponseModel> updateResponse = await client.CustomerCommunicationUpdateAsync(model.Id, request); context.Entry(context.Set <CustomerCommunication>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <CustomerCommunication>().ToList()[0].CustomerId.Should().Be(1); context.Set <CustomerCommunication>().ToList()[0].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <CustomerCommunication>().ToList()[0].EmployeeId.Should().Be(1); context.Set <CustomerCommunication>().ToList()[0].Notes.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.CustomerId.Should().Be(1); updateResponse.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.EmployeeId.Should().Be(1); updateResponse.Record.Notes.Should().Be("B"); }