public void CreatePending_QuoteItemPrepared_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var jobItemId = _jobItemForCreatePendingId; _quoteItemForCreatePending.Status = new ListItem { Id = Guid.NewGuid(), Name = "Quote Prepared", Type = ListItemType.StatusQuotedPrepared, Category = new ListItemCategory { Id = Guid.NewGuid(), Name = "Job Item Status", Type = ListItemCategoryType.JobItemStatus } }; _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, MockRepository.GenerateStub <ICompanyDetailsRepository>(), MockRepository.GenerateStub <IInvoiceRepository>(), InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId), JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending), QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending), MockRepository.GenerateStub <IListItemRepository>()); CreatePending(id, jobItemId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.QuoteStatusInvalid)); }
public void CreatePending_ApplyAllPrices_ItemCreatedWithAllPricesApplied() { var id = Guid.NewGuid(); var jobItemId = _jobItemForCreatePendingId; var invoiceItemRepositoryMock = MockRepository.GenerateMock <IInvoiceItemRepository>(); invoiceItemRepositoryMock.Stub(x => x.JobItemHasPendingInvoiceItem(jobItemId)).Return(false); invoiceItemRepositoryMock.Expect(x => x.CreatePendingItem(null)).IgnoreArguments(); _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, CompanyDetailsRepositoryTestHelper.GetCompanyDetailsRepository_StubsApplyAllPrices_ReturnsTrue(), MockRepository.GenerateStub <IInvoiceRepository>(), invoiceItemRepositoryMock, JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending), QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending), MockRepository.GenerateStub <IListItemRepository>()); CreatePending(id, jobItemId); invoiceItemRepositoryMock.VerifyAllExpectations(); Assert.AreNotEqual(Guid.Empty, _savedPendingItem.Id); Assert.IsNotNull(_savedPendingItem.JobItem); Assert.AreEqual(_quoteItemForCreatePending.JobItem.Instrument.ToString(), _savedPendingItem.Description); Assert.AreEqual(_quoteItemForCreatePending.Quote.OrderNumber, _savedPendingItem.OrderNo); Assert.AreEqual(_quoteItemForCreatePending.Calibration, _savedPendingItem.CalibrationPrice); Assert.AreEqual(_quoteItemForCreatePending.Labour, _savedPendingItem.RepairPrice); Assert.AreEqual(_quoteItemForCreatePending.Parts, _savedPendingItem.PartsPrice); Assert.AreEqual(_quoteItemForCreatePending.Carriage, _savedPendingItem.CarriagePrice); Assert.AreEqual(_quoteItemForCreatePending.Investigation, _savedPendingItem.InvestigationPrice); }
public void CreateFromPending_ValidDetailsWhenInvoiceHasOneItem_InvoiceItemSuccessfullyCreated() { var id = Guid.NewGuid(); var invoiceId = _invoiceForCreateFromPendingId; var description = "Druck, DPI601IS, Digital Pressure Indicator"; var calibrationPrice = 25; var repairPrice = 38; var partsPrice = 200; var carriagePrice = 30; var investigationPrice = 0; var invoiceRepositoryStub = MockRepository.GenerateStub <IInvoiceRepository>(); invoiceRepositoryStub.Stub(x => x.GetInvoiceItemCount(invoiceId)).Return(1); invoiceRepositoryStub.Stub(x => x.GetById(invoiceId)).Return(_invoiceForCreateFromPending); var invoiceItemRepositoryMock = MockRepository.GenerateMock <IInvoiceItemRepository>(); invoiceItemRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); var jobItemRepositoryMock = MockRepository.GenerateMock <IJobItemRepository>(); jobItemRepositoryMock.Expect(x => x.EmitItemHistory( _userContext.GetCurrentUser(), _jobItemForCreateFromPendingId, 0, 0, "Item invoiced on IR2000", ListItemType.StatusInvoiced, ListItemType.WorkTypeAdministration)); jobItemRepositoryMock.Expect(x => x.Update(_jobItemForCreateFromPending)).IgnoreArguments(); var listItemRepositoryStub = MockRepository.GenerateStub <IListItemRepository>(); listItemRepositoryStub.Stub(x => x.GetByType(ListItemType.StatusInvoiced)).Return(new ListItem { Id = Guid.NewGuid(), Name = "Invoiced", Type = ListItemType.StatusInvoiced }); _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, MockRepository.GenerateStub <ICompanyDetailsRepository>(), invoiceRepositoryStub, invoiceItemRepositoryMock, jobItemRepositoryMock, MockRepository.GenerateStub <IQuoteItemRepository>(), listItemRepositoryStub); CreateFromPending(id, invoiceId, description, calibrationPrice, repairPrice, partsPrice, carriagePrice, investigationPrice, _jobItemForCreateFromPending); invoiceItemRepositoryMock.VerifyAllExpectations(); jobItemRepositoryMock.VerifyAllExpectations(); Assert.AreNotEqual(Guid.Empty, _savedInvoiceItemFromPending.Id); Assert.AreEqual(2, _savedInvoiceItemFromPending.ItemNo); Assert.AreEqual(description, _savedInvoiceItemFromPending.Description); Assert.AreEqual(calibrationPrice, _savedInvoiceItemFromPending.CalibrationPrice); Assert.AreEqual(repairPrice, _savedInvoiceItemFromPending.RepairPrice); Assert.AreEqual(partsPrice, _savedInvoiceItemFromPending.PartsPrice); Assert.AreEqual(carriagePrice, _savedInvoiceItemFromPending.CarriagePrice); Assert.AreEqual(investigationPrice, _savedInvoiceItemFromPending.InvestigationPrice); Assert.IsNotNull(_savedInvoiceItemFromPending.Invoice); Assert.IsNotNull(_savedInvoiceItemFromPending.JobItem); Assert.AreEqual(ListItemType.StatusInvoiced, _jobItemForCreateFromPending.Status.Type); Assert.IsTrue(_jobItemForCreateFromPending.IsInvoiced); }
public void GetInvoiceItems_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { _invoiceItemService = InvoiceItemServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public), MockRepository.GenerateStub <ICompanyDetailsRepository>(), MockRepository.GenerateStub <IInvoiceRepository>(), MockRepository.GenerateStub <IInvoiceItemRepository>(), MockRepository.GenerateStub <IJobItemRepository>(), MockRepository.GenerateStub <IQuoteItemRepository>(), MockRepository.GenerateStub <IListItemRepository>()); GetInvoiceItems(); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void CreatePending_InvalidJobItemId_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var jobItemId = Guid.NewGuid(); _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, MockRepository.GenerateStub <ICompanyDetailsRepository>(), MockRepository.GenerateStub <IInvoiceRepository>(), InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId), JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsNull(jobItemId), QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending), MockRepository.GenerateStub <IListItemRepository>()); CreatePending(id, jobItemId); }
public void CreatePending_JobItemAlreadyHasPendingItem_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var jobItemId = _jobItemForCreatePendingId; _invoiceItemService = InvoiceItemServiceFactory.Create( TestUserContext.Create("*****@*****.**", "Graham Robertson", "Operations Manager", UserRole.Public), MockRepository.GenerateStub <ICompanyDetailsRepository>(), MockRepository.GenerateStub <IInvoiceRepository>(), InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsTrue(jobItemId), JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending), QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsQuoteItem(jobItemId, _quoteItemForCreatePending), MockRepository.GenerateStub <IListItemRepository>()); CreatePending(id, jobItemId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.JobItemHasPendingItem)); }
public void CreatePending_QuoteItemNotRaised_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var jobItemId = _jobItemForCreatePendingId; _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, MockRepository.GenerateStub <ICompanyDetailsRepository>(), MockRepository.GenerateStub <IInvoiceRepository>(), InvoiceItemRepositoryTestHelper.GetInvoiceItemRepository_StubsJobItemHasPendingInvoiceItem_ReturnsFalse(jobItemId), JobItemRepositoryTestHelper.GetJobItemRepository_StubsGetById_ReturnsJobItem(_jobItemForCreatePending), QuoteItemRepositoryTestHelper.GetQuoteItemRepository_StubsGetQuoteItemForJobItem_ReturnsNull(jobItemId), MockRepository.GenerateStub <IListItemRepository>()); CreatePending(id, jobItemId); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.QuoteItemNull)); }
public void CreateFromPending_InvalidInvoiceId_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var invoiceId = Guid.NewGuid(); var description = "Druck, DPI601IS, Digital Pressure Indicator"; var calibrationPrice = 25; var repairPrice = 38; var partsPrice = 200; var carriagePrice = 30; var investigationPrice = 0; var invoiceItemRepositoryMock = MockRepository.GenerateMock <IInvoiceItemRepository>(); invoiceItemRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); _invoiceItemService = InvoiceItemServiceFactory.Create( _userContext, MockRepository.GenerateStub <ICompanyDetailsRepository>(), InvoiceRepositoryTestHelper.GetInvoiceRepository_StubsGetById_ReturnsNull(invoiceId), invoiceItemRepositoryMock, MockRepository.GenerateStub <IJobItemRepository>(), MockRepository.GenerateStub <IQuoteItemRepository>(), MockRepository.GenerateStub <IListItemRepository>()); CreateFromPending(id, invoiceId, description, calibrationPrice, repairPrice, partsPrice, carriagePrice, investigationPrice, _jobItemForCreateFromPending); }