public void OrderStatusDraft_ExceptionThrown() { var shipment = new ShipmentBuilder().Build(); var purchaseOrder = new PurchaseOrderBuilder().Build(); Assert.Throws <PurchaseOrderTrackerException>(() => shipment.AddPurchaseOrder(purchaseOrder)); }
public void ScheduledToday_ReturnsTrue() { var shipment = new ShipmentBuilder() .EstimatedArrivalDate(DateTime.Today) .Build(); Assert.That(shipment.IsScheduledForDeliveryToday(), Is.True); }
public void Delayed_ReturnsTrue() { var shipment = new ShipmentBuilder() .EstimatedArrivalDate(DateTime.Today.AddDays(-1)) .Build(); Assert.That(shipment.IsDelayed(), Is.True); }
public void ScheduledYesterday_ReturnsFalse() { var shipment = new ShipmentBuilder() .EstimatedArrivalDate(DateTime.Today.AddDays(-1)) .Build(); Assert.That(shipment.IsScheduledForDeliveryToday(), Is.False); }
public void ShippedStatus_ReturnsTrue() { var shipment = new ShipmentBuilder().Build(); shipment.UpdateStatus(ShipmentStatus.Trigger.Shipped); Assert.That(shipment.CanBeDeleted, Is.True); }
public void NotDelayed_ReturnsFalse() { var shipment = new ShipmentBuilder() .EstimatedArrivalDate(DateTime.Today.AddDays(1)) .Build(); Assert.That(shipment.IsDelayedMoreThan7Days(), Is.False); }
public void OrderStatusPendingApproval_ExceptionThrown() { var shipment = new ShipmentBuilder().Build(); var purchaseOrder = new PurchaseOrderBuilder().Build(); purchaseOrder.UpdateStatus(PurchaseOrderStatus.Trigger.PendingApproval); Assert.Throws <PurchaseOrderTrackerException>(() => shipment.AddPurchaseOrder(purchaseOrder)); }
public void OrderAlreadyAssignedToShipment_ExceptionThrown() { var shipment = new ShipmentBuilder().ShipmentId(123).Build(); var poShipment = new ShipmentBuilder().ShipmentId(789).Build(); var purchaseOrder = new PurchaseOrderBuilder().Shipment(poShipment).Build(); purchaseOrder.UpdateStatus(PurchaseOrderStatus.Trigger.Approved); Assert.Throws <PurchaseOrderTrackerException>(() => shipment.AddPurchaseOrder(purchaseOrder)); }
public void OrderStatusIsApproved_OrderAdded() { var shipment = new ShipmentBuilder().Build(); var purchaseOrder = new PurchaseOrderBuilder().Build(); purchaseOrder.UpdateStatus(PurchaseOrderStatus.Trigger.Approved); shipment.AddPurchaseOrder(purchaseOrder); Assert.That(shipment.PurchaseOrders.Contains(purchaseOrder), Is.True); }
public void ShipmentStatusIsShipped_ReturnsFalse() { var shipment = new ShipmentBuilder().Build(); var purchaseOrder = new PurchaseOrderBuilder().Shipment(shipment).Build(); purchaseOrder.UpdateStatus(PurchaseOrderStatus.Trigger.Approved); shipment.UpdateStatus(ShipmentStatus.Trigger.Shipped); Assert.That(shipment.Status.CurrentState, Is.EqualTo(ShipmentStatus.State.Shipped)); Assert.That(purchaseOrder.CanShipmentBeUpdated, Is.False); }
public void DelayedButDelivered_ReturnsFalse() { var shipment = new ShipmentBuilder() .EstimatedArrivalDate(DateTime.Today.AddDays(-8)) .Build(); shipment.UpdateStatus(ShipmentStatus.Trigger.Shipped); shipment.UpdateStatus(ShipmentStatus.Trigger.Delivered); Assert.That(shipment.IsDelayedMoreThan7Days(), Is.False); }
public void NullTrackingId_ThrowsArgumentNullException() { try { var shipment = new ShipmentBuilder().TrackingId(null).Build(); Assert.Fail("Expected exception to be thrown"); } catch (Exception ex) { Assert.That(ex, Is.InstanceOf <ArgumentNullException>()); Assert.That(ex.Message.ToLower(), Contains.Substring("trackingid")); } }
public void Always_AssignsValues() { var shipment = new ShipmentBuilder().Build(); Assert.That(shipment.TrackingId, Is.EqualTo("shipmentTrackingId")); Assert.That(shipment.Company, Is.EqualTo("shipmentCompany")); // compare date component only (ignore time) to ensure this test always passes // otherwise the property would need to be abstracted so that we can // always set the same value as part of this test case Assert.That(shipment.EstimatedArrivalDate.Value.Date, Is.EqualTo(DateTime.Now.Date)); Assert.That(shipment.ShippingCost, Is.EqualTo(999)); Assert.That(shipment.DestinationAddress, Is.EqualTo("shipmentDestinationAddress")); Assert.That(shipment.Comments, Is.EqualTo("shipmentComments")); }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); var categoryBuilder = new CategoryBuilder(modelBuilder.Entity <Category>()); var customerBuilder = new CustomerBuilder(modelBuilder.Entity <Customer>()); var personelBuilder = new PersonelBuilder(modelBuilder.Entity <Personel>()); var productBuilder = new ProductBuilder(modelBuilder.Entity <Product>()); var saleBuilder = new SaleBuilder(modelBuilder.Entity <Sale>()); var shipmentBuilder = new ShipmentBuilder(modelBuilder.Entity <Shipment>()); var stockBuilder = new StockBuilder(modelBuilder.Entity <Stock>()); modelBuilder.Conventions.Remove <OneToManyCascadeDeleteConvention>(); }
public void UpdateToShipped_UpdatesAllPurchaseOrdersToShipped() { var purchaseOrder1 = new PurchaseOrderBuilder().Build(); purchaseOrder1.UpdateStatus(PurchaseOrderStatus.Trigger.Approved); var purchaseOrder2 = new PurchaseOrderBuilder().Build(); purchaseOrder2.UpdateStatus(PurchaseOrderStatus.Trigger.Approved); var shipment = new ShipmentBuilder() .PurchaseOrders(new List <PurchaseOrder>(new[] { purchaseOrder1, purchaseOrder2 })) .Build(); shipment.UpdateStatus(ShipmentStatus.Trigger.Shipped); Assert.That( shipment.PurchaseOrders.All(p => p.Status.CurrentState == PurchaseOrderStatus.State.Shipped), Is.True); }
private void RaiseAddLineItemInteractionRequest() { var itemVM = _wizardLineItemVmFactory.GetViewModelInstance(); var confirmation = new ConditionalConfirmation { Title = "Add new items".Localize(), Content = itemVM }; CommonShipmentConfirmRequest.Raise(confirmation, (x) => { if (x.Confirmed) { ParentViewModel.CloseAllSubscription1(); var builder = new ShipmentBuilder(CurrentShipment, _currentOrder.OrderForms[0], _entityFactory, _repositoryFactory, _priceListClient); itemVM.SelectedItemsToAdd.ToList().ForEach(i => builder.AddShipmentItem(i.ItemToAdd, i.Quantity)); ParentViewModel.Recalculate(); // fake assignment for triggers to fire ParentViewModel.InnerItem.OrderGroupId = ParentViewModel.InnerItem.OrderGroupId; } }); }
public void Always_DefaultStatusToOpen() { var shipment = new ShipmentBuilder().Build(); Assert.That(shipment.Status.CurrentState, Is.EqualTo(ShipmentStatus.State.Open)); }
public void Always_DefaultPurchaseOrdersAsEmptyCollection() { var shipment = new ShipmentBuilder().Build(); Assert.That(shipment.PurchaseOrders, Is.Empty); }
public void OpenStatus_ReturnsTrue() { var shipment = new ShipmentBuilder().Build(); Assert.That(shipment.CanBeDeleted, Is.True); }
public void Always_DefaultIdentifier() { var shipment = new ShipmentBuilder().Build(); Assert.That(shipment.Id, Is.EqualTo(default(int))); }
private void RaiseAddLineItemInteractionRequest() { var itemVM = _wizardLineItemVmFactory.GetViewModelInstance(); var confirmation = new ConditionalConfirmation { Title = "Add new items", Content = itemVM }; CommonShipmentConfirmRequest.Raise(confirmation, (x) => { if (x.Confirmed) { ParentViewModel.CloseAllSubscription1(); var builder = new ShipmentBuilder(CurrentShipment, _currentOrder.OrderForms[0], _entityFactory, _repositoryFactory, _priceListClient); itemVM.SelectedItemsToAdd.ToList().ForEach(i => builder.AddShipmentItem(i.ItemToAdd, i.Quantity)); ParentViewModel.Recalculate(); // fake assignment for triggers to fire ParentViewModel.InnerItem.OrderGroupId = ParentViewModel.InnerItem.OrderGroupId; } }); }
public void SetUp() { _mockedShipmentBuilder = new Mock <ShipmentBuilder>(); _shipmentBuilder = _mockedShipmentBuilder.Object; }
// GET: Shipment public ActionResult Index() { ShipmentModel shipmentModel = ShipmentBuilder.GetShipmentList(db); return(View(shipmentModel)); }