public void CreateCustomerIntegrationTest() { string returnMessage; TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); List <PaymentType> paymentTypes = customerApplicationService.GetPaymentTypes(out transaction); var paymentType = (from p in paymentTypes where p.Description == "Visa" select p).First(); Customer customer = new Customer(); customer.FirstName = "William"; customer.LastName = "Gates"; customer.EmailAddress = "*****@*****.**"; customer.PhoneNumber = "08615976111157"; customer.Address = "One Microsoft Way"; customer.City = "Redmond"; customer.Region = "WA"; customer.PostalCode = "98052-7329"; customer.PaymentTypeID = paymentType.PaymentTypeID; customer.CreditCardExpirationDate = Convert.ToDateTime("12/31/2014"); customer.CreditCardSecurityCode = "111"; customer.CreditCardNumber = "123111234"; customerApplicationService.CreateCustomer(customer, out transaction); returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage); Assert.AreEqual(true, transaction.ReturnStatus, returnMessage); }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req) { if (req.Method == HttpMethod.Get) { string id = req.GetQueryNameValuePairs() .FirstOrDefault(q => q.Key == "id") .Value; if (!string.IsNullOrEmpty(id)) { MongoConfig.RegisterMappings(); var mongoClient = new MongoClient(ConfigurationManager.AppSettings["MongoDbConnectionString"]); var customersCollection = mongoClient.GetDatabase(ConfigurationManager.AppSettings["MongoDbDatabase"]) .GetCollection <RoboBank.Customer.Domain.Customer>("customers"); var customerApplicationService = new CustomerApplicationService(new MongoCustomerRepository(customersCollection), new Application.Adapters.Mapper()); var customerInfo = await customerApplicationService.GetByIdAsync(id); if (customerInfo != null) { return(req.CreateResponse(HttpStatusCode.OK, AutoMapper.Mapper.Map <CustomerInfo, CustomerModel>(customerInfo))); } } return(req.CreateResponse(HttpStatusCode.NotFound)); } return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Method not supported")); }
public void UpdateCustomerIntegrationTest() { string returnMessage; TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = 1; paging.PageSize = 15; paging.SortExpression = "LastName"; paging.SortDirection = "ASC"; List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry("", "", paging, out transaction); var customerInformation = (from c in customers select c).First(); Guid customerID = customerInformation.CustomerID; Customer customer = customerApplicationService.GetCustomerByCustomerID(customerID, out transaction); customerApplicationService.UpdateCustomer(customer, out transaction); returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage); Assert.AreEqual(true, transaction.ReturnStatus, returnMessage); }
public void ValidateCustomerWithCheckPayment() { TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); List <PaymentType> paymentTypes = customerApplicationService.GetPaymentTypes(out transaction); var paymentType = (from p in paymentTypes where p.Description == "Check" select p).First(); Customer customer = new Customer(); customer.FirstName = "Bill"; customer.LastName = "Gates"; customer.EmailAddress = "*****@*****.**"; customer.PhoneNumber = "15976111157"; customer.PaymentTypeID = paymentType.PaymentTypeID; customer.CreditLimit = 1000.00m; customerDataService.CreateSession(); CustomerBusinessRules customerBusinessRules = new CustomerBusinessRules(); customerBusinessRules.ValidateCustomer(customer, customerDataService); customerDataService.CloseSession(); string returnMessage = Utilities.GetReturnMessage(customerBusinessRules.ValidationMessage); Assert.AreEqual(true, customerBusinessRules.ValidationStatus, returnMessage); }
public void ValidateCustomerWithCreditCardPayment() { TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); List <PaymentType> paymentTypes = customerApplicationService.GetPaymentTypes(out transaction); var paymentType = (from p in paymentTypes where p.Description == "Visa" select p).First(); Customer customer = new Customer(); customer.FirstName = "Bill"; customer.LastName = "Gates"; customer.EmailAddress = "*****@*****.**"; customer.PhoneNumber = "15976111157"; customer.PaymentTypeID = paymentType.PaymentTypeID; customer.CreditCardNumber = "1112223333"; customer.CreditCardExpirationDate = Convert.ToDateTime("12/31/2014"); customer.CreditCardSecurityCode = "111"; customerDataService.CreateSession(); CustomerBusinessRules customerBusinessRules = new CustomerBusinessRules(); customerBusinessRules.ValidateCustomer(customer, customerDataService); customerDataService.CloseSession(); string returnMessage = Utilities.GetReturnMessage(customerBusinessRules.ValidationMessage); Assert.AreEqual(true, customerBusinessRules.ValidationStatus, returnMessage); }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req) { if (req.Method == HttpMethod.Post) { MongoConfig.RegisterMappings(); var customer = await req.Content.ReadAsAsync <CustomerModel>(); if (customer != null) { var customerInfo = AutoMapper.Mapper.Map <CustomerModel, CustomerInfo>(customer); var mongoClient = new MongoClient(ConfigurationManager.AppSettings["MongoDbConnectionString"]); var customersCollection = mongoClient.GetDatabase(ConfigurationManager.AppSettings["MongoDbDatabase"]) .GetCollection <RoboBank.Customer.Domain.Customer>("customers"); var customerApplicationService = new CustomerApplicationService(new MongoCustomerRepository(customersCollection), new Application.Adapters.Mapper()); await customerApplicationService.UpdateAsync(customerInfo); return(req.CreateResponse(HttpStatusCode.OK)); } } return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Method not supported")); }
public HttpResponseMessage CustomerInquiry(string FirstName, string LastName, int CurrentPageNumber, string SortExpression, string SortDirection, int PageSize) { TransactionalInformation transaction; if (FirstName == null) { FirstName = string.Empty; } if (LastName == null) { LastName = string.Empty; } if (SortDirection == null) { SortDirection = string.Empty; } if (SortExpression == null) { SortExpression = string.Empty; } CustomerInquiryViewModel customerInquiryViewModel = new CustomerInquiryViewModel(); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = CurrentPageNumber; paging.PageSize = PageSize; paging.SortExpression = SortExpression; paging.SortDirection = SortDirection; if (paging.SortDirection == "") { paging.SortDirection = "ASC"; } if (paging.SortExpression == "") { paging.SortExpression = "LastName"; } CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry(FirstName, LastName, paging, out transaction); customerInquiryViewModel.Customers = customers; customerInquiryViewModel.ReturnStatus = transaction.ReturnStatus; customerInquiryViewModel.ReturnMessage = transaction.ReturnMessage; customerInquiryViewModel.TotalPages = paging.TotalPages; customerInquiryViewModel.TotalRows = paging.TotalRows; customerInquiryViewModel.PageSize = paging.PageSize; if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <CustomerInquiryViewModel>(HttpStatusCode.OK, customerInquiryViewModel); return(response); } var badResponse = Request.CreateResponse <CustomerInquiryViewModel>(HttpStatusCode.BadRequest, customerInquiryViewModel); return(badResponse); }
public HttpResponseMessage SeedData(HttpRequestMessage request) { TransactionalInformation transaction; SeedDataViewModel seedDataViewModel = new SeedDataViewModel(); SeedData seedData = new SeedData(); List <Customer> customers = seedData.LoadDataSet(out transaction); if (transaction.ReturnStatus == false) { seedDataViewModel.ReturnStatus = false; seedDataViewModel.ReturnMessage = transaction.ReturnMessage; var badresponse = Request.CreateResponse <SeedDataViewModel>(HttpStatusCode.BadRequest, seedDataViewModel); return(badresponse); } long startTickCount = System.Environment.TickCount; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); customerApplicationService.DeleteAllCustomers(out transaction); if (transaction.ReturnStatus == false) { seedDataViewModel.ReturnStatus = false; seedDataViewModel.ReturnMessage = transaction.ReturnMessage; var badresponse = Request.CreateResponse <SeedDataViewModel>(HttpStatusCode.BadRequest, seedDataViewModel); return(badresponse); } foreach (Customer customer in customers) { customerApplicationService.CreateCustomer(customer, out transaction); if (transaction.ReturnStatus == false) { transaction.ReturnMessage.Add("for " + customer.LastName + "," + customer.FirstName); seedDataViewModel.ReturnStatus = false; seedDataViewModel.ReturnMessage = transaction.ReturnMessage; var badresponse = Request.CreateResponse <SeedDataViewModel>(HttpStatusCode.BadRequest, seedDataViewModel); return(badresponse); } } long endTickCount = System.Environment.TickCount; decimal ticks = ((endTickCount - startTickCount) / 1000) / 60; List <String> returnMessage = new List <String>(); returnMessage.Add(customers.Count.ToString() + " customers created in " + ticks.ToString() + " minutes"); seedDataViewModel.ReturnStatus = true; seedDataViewModel.ReturnMessage = returnMessage; var response = Request.CreateResponse <SeedDataViewModel>(HttpStatusCode.OK, seedDataViewModel); return(response); }
public void deleteCustomerOkTest() { Mock <ICustomerDomainService> mock = new Mock <ICustomerDomainService>(); mock.Setup(x => x.DeleteCustomer(It.IsAny <TSeg_Clientes>())).Returns(1); CustomerApplicationService test = new CustomerApplicationService(mock.Object); var response = test.DeleteCustomer(1); Assert.IsTrue(response > 0); }
public void readCustomerByIdWithoutResultTest() { Mock <ICustomerDomainService> mock = new Mock <ICustomerDomainService>(); mock.Setup(x => x.ReadCustomerById(It.IsAny <long>())).Returns(getTSegPolizaNull()); CustomerApplicationService test = new CustomerApplicationService(mock.Object); var response = test.ReadCustomerById(100); Assert.IsTrue(response == null); }
public void readCustomerByIdOkTest() { Mock <ICustomerDomainService> mock = new Mock <ICustomerDomainService>(); mock.Setup(x => x.ReadCustomerById(It.IsAny <long>())).Returns(getTSegCliente()); CustomerApplicationService test = new CustomerApplicationService(mock.Object); var response = test.ReadCustomerById(1); Assert.IsTrue(response.id > 0); }
public void readCustomerOkTest() { Mock <ICustomerDomainService> mock = new Mock <ICustomerDomainService>(); mock.Setup(x => x.ReadCustomers()).Returns(getTSegClienteList()); CustomerApplicationService test = new CustomerApplicationService(mock.Object); var response = test.ReadCustomers(); Assert.IsTrue(response.Count > 0); }
public void createCustomerOkTest() { Mock <ICustomerDomainService> mock = new Mock <ICustomerDomainService>(); mock.Setup(x => x.CreateCustomer(It.IsAny <TSeg_Clientes>())).Returns(getTSegCliente()); CustomerApplicationService test = new CustomerApplicationService(mock.Object); var response = test.CreateCustomer(getCustomerRequest()); Assert.IsTrue(response.id > 0); }
public async void UpdateCustomerTest() { //Set up fixture var optionsBuilder = new DbContextOptionsBuilder <TripPlannerDbContext>(); optionsBuilder.UseInMemoryDatabase(); using (var context = new TripPlannerDbContext(optionsBuilder.Options)) { //Add a customer to the database var customerToUpdate = new Customer() { FirstName = "A", LastName = "B", DateOfBirth = DateTime.Today.AddYears(-32), StreetAddress = "A", Suburb = "C", Postcode = "2222", State = "NSW" }; context.Customers.Add(customerToUpdate); context.SaveChanges(); //uppdate the customer using the service //Execute SUT var service = new CustomerApplicationService(context); var newCustomerInfo = new RegisterCustomerCommand() { FirstName = "JUAN", LastName = "RONDON", DateOfBirth = DateTime.Today.AddYears(-30), StreetAddress = "ONE ADDRESS", Suburb = "ONE SUBURB", Postcode = "0000", State = "VIC" }; var updatedCustomer = await service.Update(1, newCustomerInfo); //Verify Outcomes Assert.Equal(newCustomerInfo.FirstName, updatedCustomer.FirstName); Assert.Equal(newCustomerInfo.LastName, updatedCustomer.LastName); Assert.Equal(newCustomerInfo.DateOfBirth, updatedCustomer.DateOfBirth); Assert.Equal(newCustomerInfo.StreetAddress, updatedCustomer.StreetAddress); Assert.Equal(newCustomerInfo.Suburb, updatedCustomer.Suburb); Assert.Equal(newCustomerInfo.Postcode, updatedCustomer.Postcode); Assert.Equal(newCustomerInfo.State, updatedCustomer.State); } }
public void CustomerInquiryIntegrationTest() { TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = 1; paging.PageSize = 15; paging.SortExpression = "LastName"; paging.SortDirection = "ASC"; List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry("", "", paging, out transaction); string returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage); Assert.AreEqual(15, customers.Count, returnMessage); }
public HttpResponseMessage UpdateCustomer(HttpRequestMessage request, [FromBody] CustomerMaintenanceDTO customerDTO) { TransactionalInformation transaction; CustomerMaintenanceViewModel customerMaintenanceViewModel = new CustomerMaintenanceViewModel(); if (!ModelState.IsValid) { var errors = ModelState.Errors(); customerMaintenanceViewModel.ReturnMessage = ModelStateHelper.ReturnErrorMessages(errors); customerMaintenanceViewModel.ValidationErrors = ModelStateHelper.ReturnValidationErrors(errors); customerMaintenanceViewModel.ReturnStatus = false; var badresponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel); return(badresponse); } Customer customer = new Customer(); ModelStateHelper.UpdateViewModel(customerDTO, customer); CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); customerApplicationService.UpdateCustomer(customer, out transaction); customerMaintenanceViewModel.Customer = customer; customerMaintenanceViewModel.ReturnStatus = transaction.ReturnStatus; customerMaintenanceViewModel.ReturnMessage = transaction.ReturnMessage; customerMaintenanceViewModel.ValidationErrors = transaction.ValidationErrors; if (transaction.ReturnStatus == false) { var badresponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel); return(badresponse); } else { var response = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.Created, customerMaintenanceViewModel); return(response); } }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req) { if (req.Method == HttpMethod.Get) { MongoConfig.RegisterMappings(); var mongoClient = new MongoClient(ConfigurationManager.AppSettings["MongoDbConnectionString"]); var customersCollection = mongoClient.GetDatabase(ConfigurationManager.AppSettings["MongoDbDatabase"]) .GetCollection <RoboBank.Customer.Domain.Customer>("customers"); var customerApplicationService = new CustomerApplicationService(new MongoCustomerRepository(customersCollection), new Application.Adapters.Mapper()); var customerInfos = await customerApplicationService.SearchAsync(req.GetQueryNameValuePairs()); return(req.CreateResponse(HttpStatusCode.OK, AutoMapper.Mapper.Map <List <CustomerInfo>, List <CustomerModel> >(customerInfos.ToList()))); } return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Method not supported")); }
public HttpResponseMessage GetCustomerMaintenanceInformation(HttpRequestMessage request, Guid customerID) { TransactionalInformation customerTransaction; TransactionalInformation paymentTransaction; CustomerMaintenanceViewModel customerMaintenanceViewModel = new CustomerMaintenanceViewModel(); CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); if (customerID != Guid.Empty) { Customer customer = customerApplicationService.GetCustomerByCustomerID(customerID, out customerTransaction); customerMaintenanceViewModel.Customer = customer; customerMaintenanceViewModel.ReturnStatus = customerTransaction.ReturnStatus; customerMaintenanceViewModel.ReturnMessage = customerTransaction.ReturnMessage; } List <PaymentType> paymentTypes = customerApplicationService.GetPaymentTypes(out paymentTransaction); customerMaintenanceViewModel.PaymentTypes = paymentTypes; if (paymentTransaction.ReturnStatus == false) { customerMaintenanceViewModel.ReturnStatus = paymentTransaction.ReturnStatus; customerMaintenanceViewModel.ReturnMessage = paymentTransaction.ReturnMessage; } if (customerMaintenanceViewModel.ReturnStatus == true) { var response = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.OK, customerMaintenanceViewModel); return(response); } var badResponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel); return(badResponse); }
public CustomerController(CustomerApplicationService service) { _service = service; }
public CustomerController(CustomerApplicationService customerApplicationService) { _customerApplicationService = customerApplicationService; }
public CustomerCommandsApi(CustomerApplicationService applicationService, IBus bus) { _applicationService = applicationService; _bus = bus; }
public CustomersController() { CustomerApplicationService = new CustomerApplicationService(); PolicyApplicationService = new PolicyApplicationService(); CustomerPolicyApplicationService = new CustomerPolicyApplicationService(); }
public CustomerContoller(CustomerApplicationService customerService) { this.customerService = customerService; }