Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
 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));
 }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
 public void Setup()
 {
     _supplierService           = SupplierServiceFactory.Create();
     _domainValidationException = null;
 }