public async void Edit_Order_Valid(OrderDetailModel order) { var mockItemService = new Mock <IItemService>(); var mockCustomerService = new Mock <ICustomerService>(); var mockOrderService = new Mock <IOrderService>(); mockOrderService.Setup(x => x.Update(It.IsAny <Order>())) .ReturnsAsync(1); order.BillingAddress = TestUtilities.GetValidAddress(); order.ShippingAddress = TestUtilities.GetValidAddress(); order.Cart.Clear(); order.Cart.Add(TestUtilities.GetValidOrderItem()); order.Status = OrderStatus.Sent; order.BillingContact = TestUtilities.GetValidContact(); IMapper mapper = TestUtilities.GetMapper(new ItemProfile(), new OrderProfile(), new SharedProfile()); OrderManager manager = new OrderManager(_logger, mapper, mockOrderService.Object, mockItemService.Object, mockCustomerService.Object, Mock.Of <IShipmentService>(), _eventService, Mock.Of <IIsotopeOrderingAuthorizationService>()); ApplicationResult result = await manager.Edit(order); _output.WriteLine(result.Message); CustomAssertions.AssertValidationErrorsDoNotExist(result); }
public async void Edit_Customer_Without_Validation_Errors(CustomerDetailModel model) { IMapper mapper = TestUtilities.GetMapper(new CustomerProfile(), new SharedProfile()); var mock = new Mock <ICustomerService>(); mock.Setup(x => x.Update(It.IsAny <Customer>())).ReturnsAsync(1); AddressDetailModel address = new Fixture().Create <AddressDetailModel>(); address.State = "MO"; address.ZipCode = "12345"; model.Addresses.Clear(); model.Addresses.Add(new CustomerAddressDetailModel() { Address = address, Type = AddressType.Billing }); model.Addresses.Add(new CustomerAddressDetailModel() { Address = address, Type = AddressType.Shipping }); model.Contact.Email = "*****@*****.**"; model.Contact.Fax = "123-1234"; model.Contact.PhoneNumber = "123-1234"; model.Institutions.Clear(); model.ItemConfigurations.Clear(); model.Documents.Clear(); CustomerManager manager = new CustomerManager(_logger, mapper, mock.Object, Mock.Of <IUserService>(), Mock.Of <IIsotopeOrderingAuthorizationService>(), _eventService, Mock.Of <INotificationService>()); ApplicationResult applicationResult = await manager.Edit(model); _output.WriteLine(applicationResult.Message); CustomAssertions.AssertValidationErrorsDoNotExist(applicationResult); }
public async void Update_Form_Status() { var mockFormService = new Mock <IFormService>(); mockFormService.Setup(x => x.UpdateCustomerFormStatus(It.IsAny <int>(), It.IsAny <CustomerFormStatus>())).Returns(Task.CompletedTask); IMapper mapper = TestUtilities.GetMapper(new CustomerProfile(), new FormProfile(), new InstitutionProfile()); FormManager manager = new FormManager(_logger, mapper, mockFormService.Object, Mock.Of <IItemService>(), Mock.Of <IIsotopeOrderingAuthorizationService>(), Mock.Of <ICustomerService>(), _eventService, Mock.Of <INotificationManager>()); ApplicationResult result = await manager.UpdateFormStatus(1, 1, CustomerFormStatus.Approved); CustomAssertions.AssertValidationErrorsDoNotExist(result); }
public async void Delete_Item() { var mockItemService = new Mock <IItemService>(); mockItemService.Setup(x => x.Delete(It.IsAny <int>())).ReturnsAsync(1); IMapper mapper = TestUtilities.GetMapper(new ItemProfile()); ItemManager manager = new ItemManager(_logger, mapper, mockItemService.Object); ApplicationResult result = await manager.Delete(1); CustomAssertions.AssertValidationErrorsDoNotExist(result); }
public async void Submit_Valid_InitiationForm(FormDetailModel form) { var mockFormService = new Mock <IFormService>(); mockFormService.Setup(x => x.SubmitCustomerForm(It.IsAny <CustomerForm>())).ReturnsAsync(1); IMapper mapper = TestUtilities.GetMapper(new CustomerProfile(), new FormProfile(), new InstitutionProfile()); FormManager manager = new FormManager(_logger, mapper, mockFormService.Object, Mock.Of <IItemService>(), Mock.Of <IIsotopeOrderingAuthorizationService>(), Mock.Of <ICustomerService>(), _eventService, Mock.Of <INotificationManager>()); List <FormInitiationItemModel> items = new List <FormInitiationItemModel>() { new FormInitiationItemModel() { IsSelected = true } }; Fixture fixture = new Fixture(); AddressDetailModel address = fixture.Create <AddressDetailModel>(); address.State = "MO"; address.ZipCode = "12345"; ContactDetailModel contact = fixture.Create <ContactDetailModel>(); contact.Email = "*****@*****.**"; contact.PhoneNumber = "123-123-1234"; form.InitiationModel = new FormInitiationDetailModel() { Institution = new InstitutionDetailModel() { Name = "Test", Address = address, FinancialContact = contact, SafetyContact = contact }, ShippingAddress = address, Items = items }; form.CustomerDetailFormId = 1; form.InitiationModel.CustomerAdminSignature.Email = "*****@*****.**"; form.InitiationModel.CustomerAdminSignature.PhoneNumber = "123-123-1234"; ApplicationResult result = await manager.SubmitInitiationForm(form); _output.WriteLine(result.Message); CustomAssertions.AssertValidationErrorsDoNotExist(result); }
public async void Create_Item_Valid(ItemDetailModel model) { var mockItemService = new Mock <IItemService>(); mockItemService.Setup(x => x.Create(It.IsAny <Item>())).ReturnsAsync(1); IMapper mapper = TestUtilities.GetMapper(new ItemProfile()); ItemManager manager = new ItemManager(_logger, mapper, mockItemService.Object); model.DefaultMinQuantity = 10; model.DefaultMaxQuantity = 10; ApplicationResult result = await manager.Create(model); _output.WriteLine(result.Message); CustomAssertions.AssertValidationErrorsDoNotExist(result); }