public void AnalyseMovementToWorkstationShouldAddDeliveryPoint() { StoragePoint deliveryPoint = null; var store = new Store { Name = "B01" }; var shelf = new Shelf { Number = "1" }; for (int i = 0; i < 4; i++) { shelf.Parts.Add(new Part { Position = i }); } store.Shelves.Add(shelf); var stores = new List <Store> { store }; var storagePoints = new List <StoragePoint>(); var storageSystem = new Mock <IStorageSystem>(); storageSystem.SetupGet(s => s.Stores).Returns(stores); storageSystem.SetupGet((s => s.StoragePoints)).Returns(new List <StoragePoint>()); storageSystem.SetupGet((s => s.DeliveryPoints)).Returns(storagePoints); storageSystem.Setup(s => s.RemovePartFromShelf(It.IsAny <Shelf>(), It.IsAny <Part>())) .Callback <Shelf, Part>(((shelf1, part) => shelf1.Parts.Remove(part))); storageSystem.Setup(s => s.AddDeliveryPoint(It.IsAny <StoragePoint>())).Callback <StoragePoint>(sp => { deliveryPoint = sp; storagePoints.Add(deliveryPoint); }); storageSystem.Setup(s => s.AddPartToDeliveryPoint(It.IsAny <StoragePoint>(), It.IsAny <Part>())) .Callback <StoragePoint, Part>(((sp, part) => sp.Parts.Add(part))); _useCase.StorageSystem = storageSystem.Object; var request = new MovementRequest { Ticket = Guid.NewGuid(), Info = "part to workstation", Quantity = 3, Target = "AV01", TargetCompartment = "1", Task = AutomationTasks.Transport, Source = "B01", SourceCompartment = "1", Timestamp = DateTime.UtcNow }; _useCase.Execute(request); deliveryPoint.Should().NotBeNull(); deliveryPoint.Parts.Count.Should().Be(3); }
public void AddDeliveryPointShouldSendAddDeliveryPointEvent() { StoragePoint receivedDeliveryPoint = null; var storagePoint = new StoragePoint { Name = "AV01" }; var addEvent = _eventAggregator.GetEvent <PubSubEvent <AddDeliveryPointEvent> >(); addEvent.Subscribe(a => receivedDeliveryPoint = a.DeliveryPoint); _storageSystem.AddDeliveryPoint(storagePoint); Task.Delay(25).Wait(); receivedDeliveryPoint.Should().Be(storagePoint); }
public void AddStoragePointShouldAddStoragePoint() { StoragePoint receivedStoragePoint = null; var expected = new StoragePoint(); var addStoragePointEvent = _eventAggregator.GetEvent <PubSubEvent <AddStoragePointEvent> >(); addStoragePointEvent.Subscribe(receivedEvent => receivedStoragePoint = receivedEvent.StoragePoint); _storageSystem.AddStoragePoint(expected); Task.Delay(25).Wait(); _storageSystem.StoragePoints.Count.Should().Be(1); var storagePoint = _storageSystem.StoragePoints.First(); storagePoint.Should().Be(expected); receivedStoragePoint.Should().Be(expected); }
public void AddPartToDeliveryPointShouldAddPartToDeliveryPoint() { StoragePoint receivedDeliveryPoint = null; Part receivedPart = null; var expected = new Part(); var storagePoint = new StoragePoint(); _storageSystem.DeliveryPoints.Add(storagePoint); var insertPartEvent = _eventAggregator.GetEvent <PubSubEvent <InsertPartToDeliveryEvent> >(); insertPartEvent.Subscribe(e => { receivedPart = e.Part; receivedDeliveryPoint = e.DeliveryPoint; }); _storageSystem.AddPartToDeliveryPoint(storagePoint, expected); storagePoint.Parts.Count.Should().Be(1); storagePoint.Parts.First().Should().Be(expected); receivedPart.Should().Be(expected); receivedDeliveryPoint.Should().Be(storagePoint); }
public void RemovePartFromStoragePointShouldRemovePart() { Part receivedPart = null; StoragePoint reveivedStoragePoint = null; var expectedStoragePoint = new StoragePoint(); var expected = new Part(); expectedStoragePoint.Parts.Add(expected); _storageSystem.StoragePoints.Add(expectedStoragePoint); var removePartEvent = _eventAggregator.GetEvent <PubSubEvent <RemovePartFromStoragePointEvent> >(); removePartEvent.Subscribe(e => { receivedPart = e.Part; reveivedStoragePoint = e.StoragePoint; }); _storageSystem.RemovePartFromStoragePoint(expectedStoragePoint, expected); Task.Delay(25).Wait(); expectedStoragePoint.Parts.Count.Should().Be(0); receivedPart.Should().Be(expected); reveivedStoragePoint.Should().Be(expectedStoragePoint); }