public BankAccountApplicationService(IUnitOfWork iUnitOfWork, IMapper mapper) { bankAccountDomainService = new BankAccountDomainService(); customerDomainService = new CustomerDomainService(); _iUnitOfWork = iUnitOfWork; _mapper = mapper; }
public async Task DomainServiceTest_DomainNotifications_Success() { await RunWithTelemetryAsync( totalOfExecutions : 1, runInParallel : false, handler : async execution => { #region Arrange var result = false; var domainNotificationEventHandler = ServiceProvider.GetService <DomainNotificationEventHandler>(); var domainServiceParameters = ServiceProvider.GetService <DomainServiceParameters>(); var customerDomainService = new CustomerDomainService(domainServiceParameters); #endregion #region Act await customerDomainService.SendDomainNotificationsForTest(); #endregion #region Assert result = domainNotificationEventHandler.DomainNotificationEventCollection.Count == 3 && domainNotificationEventHandler.HasNotifications && domainNotificationEventHandler.HasInformationNotifications && domainNotificationEventHandler.HasWarningNotifications && domainNotificationEventHandler.HasErrorNotifications && domainNotificationEventHandler.DomainNotificationEventCollection.Any(q => q.DomainNotificationEventType == DomainNotificationEventTypeEnum.Error) && domainNotificationEventHandler.DomainNotificationEventCollection.Any(q => q.DomainNotificationEventType == DomainNotificationEventTypeEnum.Warning) && domainNotificationEventHandler.DomainNotificationEventCollection.Any(q => q.DomainNotificationEventType == DomainNotificationEventTypeEnum.Information) ; return(result); #endregion } ).ConfigureAwait(false); }
public async Task Insert_Should_Create_Customer() { // Arrange IUnitOfWork unitOfWork = new UnitOfWork(_fixture.Context); var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerDomainService = new CustomerDomainService(customerRepository, _mapper); const string customerId = "COMP1"; const string companyName = "Company 1"; var customer = new CustomerDomainModel { CustomerId = customerId, CompanyName = companyName }; // Act customerDomainService.Insert(customer); var savedChanges = await unitOfWork.SaveChangesAsync(); // Assert Assert.Equal(1, savedChanges); var newCustomer = await customerRepository.FindAsync(customerId); Assert.Equal(newCustomer.CustomerId, customerId); Assert.Equal(newCustomer.CompanyName, companyName); }
public void readCustomerByIdWithoutResultTest() { Mock <ITSegClientesRepository> mock = new Mock <ITSegClientesRepository>(); mock.Setup(x => x.ReadTSegClienteById(It.IsAny <long>())).Returns(getTSegClienteNull()); CustomerDomainService test = new CustomerDomainService(mock.Object); var response = test.ReadCustomerById(100); Assert.IsTrue(response == null); }
public void readCustomerOkTest() { Mock <ITSegClientesRepository> mock = new Mock <ITSegClientesRepository>(); mock.Setup(x => x.ReadTSegClientes()).Returns(getTSegClienteList()); CustomerDomainService test = new CustomerDomainService(mock.Object); var response = test.ReadCustomers(); Assert.IsTrue(response.Count > 0); }
public void deleteCustomerOkTest() { Mock <ITSegClientesRepository> mock = new Mock <ITSegClientesRepository>(); mock.Setup(x => x.DeleteTSegCliente(It.IsAny <TSeg_Clientes>())); CustomerDomainService test = new CustomerDomainService(mock.Object); var response = test.DeleteCustomer(getTSegClienteRequest()); Assert.IsTrue(response > 0); }
public async Task CustomersByCompany_Should_Return_Customer() { // Arrange var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerDomainService = new CustomerDomainService(customerRepository, _mapper); const string company = "Alfreds Futterkiste"; // Act var customers = await customerDomainService.CustomersByCompany(company); // Assert Assert.Collection(customers, customer => Assert.Equal("ALFKI", customer.CustomerId)); }
public async Task SelectAsync_Should_Return_DomainModels() { // Arrange var repository = new TrackableRepository <Customer>(_fixture.Context); var customerService = new CustomerDomainService(repository, _mapper); // Act var customers = await customerService.SelectAsyncCustomers(); var enumerable = customers as CustomerDomainModel[] ?? customers.ToArray(); // Assert Assert.Equal(90, enumerable.Length); }
public async Task QueryableSql_Should_Return_Customer_Query() { // Arrange var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerDomainService = new CustomerDomainService(customerRepository, _mapper); const string companyName = "Alfreds Futterkiste"; // Act var query = customerDomainService.QueryableSql("SELECT * FROM Customers"); var customers = await query .Where(x => x.CompanyName.Contains(companyName)) .ToListAsync(); // Assert Assert.Collection(customers, customer => Assert.Equal("ALFKI", customer.CustomerId)); }
public async Task ExistsAsync_Should_Return_False(bool useKey) { // Arrange var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerService = new CustomerDomainService(customerRepository, _mapper); // Act bool result; if (useKey) { result = await customerService.ExistsAsync("TEST"); } else { result = await customerService.ExistsAsync(new object[] { "TEST" }); } // Assert Assert.False(result); }
public async Task FindAsync_Should_Return_DomainModel(bool useKey) { // Arrange var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerService = new CustomerDomainService(customerRepository, _mapper); var customerDomainModel = new CustomerDomainModel(); // Act if (useKey) { customerDomainModel = await customerService.FindAsync("ALFKI"); } else { customerDomainModel = await customerService.FindAsync(new object[] { "ALFKI" }); } // Assert Assert.Equal("ALFKI", customerDomainModel.CustomerId); Assert.NotNull(customerDomainModel); }
public async Task Update_Should_Update_Customer() { // Arrange IUnitOfWork unitOfWork = new UnitOfWork(_fixture.Context); var customerRepository = new TrackableRepository <Customer>(_fixture.Context); var customerDomainService = new CustomerDomainService(customerRepository, _mapper); const string customerId = "BERGS"; const string companyName = "Eastern Connection 1"; var data = await customerRepository.FindAsync(customerId); customerRepository.Detach(data); var customerDomainModel = new CustomerDomainModel { CustomerId = data.CustomerId, CompanyName = companyName, ContactName = data.ContactName, ContactTitle = data.ContactTitle, Address = data.Address, City = data.City, Region = data.Region, PostalCode = data.PostalCode, Country = data.Country, Phone = data.Phone, Fax = data.Fax }; // Act customerDomainService.Update(customerDomainModel); var savedChanges = await unitOfWork.SaveChangesAsync(); // Assert Assert.Equal(1, savedChanges); var updatedCustomer = await customerRepository.FindAsync(customerId); Assert.Equal(data.Address, updatedCustomer.Address); Assert.Equal(customerDomainModel.CompanyName, companyName); }
public SecurityApplicationService(IUnitOfWork iUnitOfWork, IMapper mapper) { customerDomainService = new CustomerDomainService(); _iUnitOfWork = iUnitOfWork; _mapper = mapper; }
public CustomerApplicationService(IUnitOfWork unitOfWork, IMapper mapper) { customerDomainService = new CustomerDomainService(); _iUnitOfWork = unitOfWork; _mapper = mapper; }