Beispiel #1
0
 public void GetQuotes_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
 {
     _quoteService = QuoteServiceTestHelper.CreateQuoteService(
         MockRepository.GenerateStub<IQuoteRepository>(),
         MockRepository.GenerateStub<ICustomerRepository>(),
         MockRepository.GenerateStub<ICurrencyRepository>(),
         TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public));
     GetQuotes();
     Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.InsufficientSecurity));
 }
Beispiel #2
0
        public void Create_InvalidCustomerId_ArgumentExceptionThrown()
        {
            var id = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var currencyId = Guid.NewGuid();
            var orderNo = "PO1010";
            var adviceNo = "AD1010";

            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                MockRepository.GenerateStub<IQuoteRepository>(),
                QuoteServiceTestHelper.GetCustomerRepository_StubsGetById_ReturnsNull(customerId),
                MockRepository.GenerateStub<ICurrencyRepository>(),
                _userContext);
            CreateQuote(id, customerId, orderNo, adviceNo, currencyId);
        }
Beispiel #3
0
        public void Edit_InvalidCurrencyId_ArgumentExceptionThrown()
        {
            var orderNo = "ORDER12345";
            var adviceNo = "ADV12345";
            var currencyId = Guid.NewGuid();

            var quoteRepositoryStub = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryStub.Stub(x => x.GetById(_quoteForEditId)).Return(_quoteForEdit);
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryStub,
                MockRepository.GenerateStub<ICustomerRepository>(),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsNull(currencyId),
                _userContext);
            Edit(_quoteForEditId, orderNo, adviceNo, currencyId);
        }
Beispiel #4
0
        public void Edit_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
        {
            var orderNo = "ORDER12345";
            var adviceNo = "ADV12345";
            var currencyId = Guid.NewGuid();

            var quoteRepositoryStub = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryStub.Stub(x => x.GetById(_quoteForEditId)).Return(_quoteForEdit);
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryStub,
                MockRepository.GenerateStub<ICustomerRepository>(),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member));
            Edit(_quoteForEditId, orderNo, adviceNo, currencyId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.InsufficientSecurityClearance));
        }
Beispiel #5
0
        public void Edit_AdviceNoGreaterThan50Characters_DomainValidationExceptionThrown()
        {
            var orderNo = "ORDER12345";
            var adviceNo = new string('a', 51);
            var currencyId = Guid.NewGuid();

            var quoteRepositoryStub = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryStub.Stub(x => x.GetById(_quoteForEditId)).Return(_quoteForEdit);
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryStub,
                MockRepository.GenerateStub<ICustomerRepository>(),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                _userContext);
            Edit(_quoteForEditId, orderNo, adviceNo, currencyId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.AdviceNoTooLarge));
        }
Beispiel #6
0
        public void Create_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
        {
            var id = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var currencyId = Guid.NewGuid();
            var orderNo = "PO1000";
            var adviceNo = "AD1000";

            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                MockRepository.GenerateStub<IQuoteRepository>(),
                QuoteServiceTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Member));
            CreateQuote(id, customerId, orderNo, adviceNo, currencyId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.InsufficientSecurityClearance));
        }
Beispiel #7
0
        public void Create_AdviceNoGreaterThan50Characters_DomainValidationExceptionThrown()
        {
            var id = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var currencyId = Guid.NewGuid();
            var orderNo = "PO1000";
            var adviceNo = new string('a', 51);

            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                MockRepository.GenerateStub<IQuoteRepository>(),
                QuoteServiceTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                _userContext);
            CreateQuote(id, customerId, orderNo, adviceNo, currencyId);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(JobSystem.Resources.Quotes.Messages.AdviceNoTooLarge));
        }
Beispiel #8
0
        public void Edit_MemberIsAdmin_ItemEdited()
        {
            var orderNo = "ORDER12345";
            var adviceNo = "ADV12345";
            var currencyId = Guid.NewGuid();

            var quoteRepositoryMock = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryMock.Stub(x => x.GetById(_quoteForEditId)).Return(_quoteForEdit);
            quoteRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryMock,
                MockRepository.GenerateStub<ICustomerRepository>(),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Admin | UserRole.Member));
            Edit(_quoteForEditId, orderNo, adviceNo, currencyId);
            quoteRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(orderNo, _quoteForEdit.OrderNumber);
            Assert.AreEqual(adviceNo, _quoteForEdit.AdviceNumber);
            Assert.AreEqual(currencyId, _quoteForEdit.Currency.Id);
            Assert.AreEqual(2, _quoteForEdit.Revision);
        }
Beispiel #9
0
        public void Edit_ValidQuoteDetails_ItemEdited()
        {
            var orderNo = "ORDER12345";
            var adviceNo = "ADV12345";
            var currencyId = Guid.NewGuid();

            var quoteRepositoryMock = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryMock.Stub(x => x.GetById(_quoteForEditId)).Return(_quoteForEdit);
            quoteRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryMock,
                MockRepository.GenerateStub<ICustomerRepository>(),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                _userContext);
            Edit(_quoteForEditId, orderNo, adviceNo, currencyId);
            quoteRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(orderNo, _quoteForEdit.OrderNumber);
            Assert.AreEqual(adviceNo, _quoteForEdit.AdviceNumber);
            Assert.AreEqual(currencyId, _quoteForEdit.Currency.Id);
            Assert.AreEqual(2, _quoteForEdit.Revision);
        }
Beispiel #10
0
        public void Create_ValidQuoteDetails_QuoteCreated()
        {
            var id = Guid.NewGuid();
            var customerId = Guid.NewGuid();
            var currencyId = Guid.NewGuid();
            var orderNo = "PO1010";
            var adviceNo = "AD1010";

            var quoteRepositoryMock = MockRepository.GenerateMock<IQuoteRepository>();
            quoteRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments();
            _quoteService = QuoteServiceTestHelper.CreateQuoteService(
                quoteRepositoryMock,
                QuoteServiceTestHelper.GetCustomerRepository_StubsGetById_ReturnsCustomer(customerId),
                CurrencyRepositoryTestHelper.GetCurrencyRepository_StubsGetById_ReturnsGbpCurrency(currencyId),
                _userContext);
            CreateQuote(id, customerId, orderNo, adviceNo, currencyId);
            quoteRepositoryMock.VerifyAllExpectations();
            Assert.AreNotEqual(Guid.Empty, _savedQuote.Id);
            Assert.That(_savedQuote.QuoteNumber.StartsWith("QR"));
            Assert.AreEqual(_dateCreated, _savedQuote.DateCreated);
            Assert.AreEqual("*****@*****.**", _savedQuote.CreatedBy.EmailAddress);
            Assert.AreEqual(1, _savedQuote.Revision);
            Assert.IsTrue(_savedQuote.IsActive);
        }