public void Edit_InvalidIdSupplied_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var supplierRepositoryStub = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(id)).Return(null); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); EditSupplier(id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); }
public void Edit_NameGreaterThan255Characters_DomainValidationExceptionThrown() { var supplier = GetSupplierToEdit(); var supplierRepositoryStub = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(supplier.Id)).Return(supplier); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); EditSupplier(supplier.Id, new string('a', 256), GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.NameTooLarge)); }
public void Edit_NameNotSupplied_DomainValidationExceptionThrown() { var supplier = GetSupplierToEdit(); var supplierRepositoryStub = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(supplier.Id)).Return(supplier); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); EditSupplier(supplier.Id, String.Empty, GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.NameRequired)); }
public void Create_NameGreaterThan256Characters_DomainValidationExceptionThrown() { var supplierRepositoryStub = MockRepository.GenerateStub <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetByName("Gael Ltd")).Return(null); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); CreateSupplier( Guid.NewGuid(), new string('a', 256), GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.NameTooLarge)); }
public void Edit_ValidSupplierDetails_SupplierEdited() { var supplier = GetSupplierToEdit(); var supplierRepositoryMock = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments(); supplierRepositoryMock.Stub(x => x.GetById(supplier.Id)).Return(supplier); _supplierService = SupplierServiceFactory.Create(supplierRepositoryMock); EditSupplier(supplier.Id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); supplierRepositoryMock.VerifyAllExpectations(); }
public void Create_NonUniqueName_DomainValidationExceptionThrown() { var supplierRepositoryStub = MockRepository.GenerateStub <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetByName("Gael Ltd")).Return(new Supplier { Name = "Gael Ltd" }); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); CreateSupplier( Guid.NewGuid(), "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.DuplicateName)); }
public void Create_SuccessfullyCreateSupplier_SupplierCreated() { var supplierRepositoryMock = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); supplierRepositoryMock.Stub(x => x.GetByName("Gael Ltd")).Return(null); _supplierService = SupplierServiceFactory.Create(supplierRepositoryMock); CreateSupplier( Guid.NewGuid(), "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); supplierRepositoryMock.VerifyAllExpectations(); Assert.That(_savedSupplier.Id != Guid.Empty); }
public void Edit_NonUniqueName_DomainValidationExceptionThrown() { var nonUniqueSupplier = GetNonUniqueSupplierForEdit(); var supplier = GetSupplierToEdit(); var supplierRepositoryStub = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(supplier.Id)).Return(supplier); supplierRepositoryStub.Stub(x => x.GetByName(nonUniqueSupplier.Name)).Return(nonUniqueSupplier); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); EditSupplier(supplier.Id, nonUniqueSupplier.Name, GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), GetContactInfo("Sales")); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.DuplicateName)); }
public void GetSuppliers_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { try { _supplierService = SupplierServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Public)); _supplierService.GetSuppliers(); } catch (DomainValidationException dex) { _domainValidationException = dex; } Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void Edit_SalesTelephoneGreaterThan50Characters_DomainValidationExceptionThrown() { var supplier = GetSupplierToEdit(); var supplierRepositoryStub = MockRepository.GenerateMock <ISupplierRepository>(); supplierRepositoryStub.Stub(x => x.GetById(supplier.Id)).Return(supplier); _supplierService = SupplierServiceFactory.Create(supplierRepositoryStub); var salesContactInfo = GetContactInfo("Sales"); salesContactInfo.Telephone = new string('a', 51); EditSupplier(supplier.Id, "Gael Ltd", GetAddressDetails("Trading"), GetContactInfo("Trading"), GetAddressDetails("Sales"), salesContactInfo); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ContactInfoTooLarge)); }
public void Setup() { _supplierService = SupplierServiceFactory.Create(); _domainValidationException = null; }