public void ExecuteShouldWriteResponseFile() { MovementResponse response = null; var sendResponseUseCase = new Mock <ISendResponseUseCase>(); sendResponseUseCase.Setup(s => s.Execute(It.IsAny <MovementResponse>())) .Callback <MovementResponse>(movementResponse => response = movementResponse); var expectedTicket = Guid.NewGuid(); var expectedTimestamp = DateTime.UtcNow; var expected = new MovementRequest() { Info = "info", Quantity = 2, Source = "source", Target = "target", Task = AutomationTasks.Transport, Ticket = expectedTicket, Timestamp = expectedTimestamp, SourceCompartment = "2", TargetCompartment = "3", }; expected.Data.Add(new MovementData { Barcode = "barcode", Index = "2" }); ISendStoragePointOccupiedUseCase useCase = new SendStoragePointOccupiedUseCase(sendResponseUseCase.Object); useCase.Execute(expected); response.Should().NotBeNull(); response.Info.Should().Be("Storage point occupied: info"); response.Quantity.Should().Be(2); response.Source.Should().Be("source"); response.Target.Should().Be("target"); response.Status.Should().Be(AutomationStatus.InsertionFailed); response.Ticket.Should().Be(expectedTicket); response.TimestampString.Should().Be(expectedTimestamp.ToString("dd.MM.yyyy hh:mm:ss")); response.SourceCompartment.Should().Be("2"); response.TargetCompartment.Should().Be("3"); }
public void IfResponseExistsExecuteShouldThrowIOException() { var eventAggregator = new Mock <IEventAggregator>(); var responseEvent = new Mock <PubSubEvent <MovementResponseEvent> >(); eventAggregator.Setup(ea => ea.GetEvent <PubSubEvent <MovementResponseEvent> >()).Returns(responseEvent.Object); var responsePath = $"./responsePath"; var responseFile = $"{responsePath}/MovementResponse_V.xml"; var expectedTicket = Guid.NewGuid(); var expectedTimestamp = DateTime.UtcNow; var expected = new MovementResponse() { Info = "info", Quantity = 2, Source = "source", Target = "target", Status = AutomationStatus.InsertionSucceeded, Ticket = expectedTicket, Timestamp = expectedTimestamp, SourceCompartment = "2", TargetCompartment = "3", }; expected.Data.Add(new MovementData { Barcode = "barcode", Index = "2" }); PrepareResponseDirectory(responsePath); Directory.CreateDirectory(responsePath); using (var stream = File.Create(responseFile)) { stream.Flush(); stream.Close(); } var config = new Mock <IStorageSimulatorConfig>(); config.Setup(c => c.CommunicationPath).Returns(responsePath); ISendResponseUseCase useCase = new SendResponseUseCase(config.Object, eventAggregator.Object); var exception = Assert.Throws <IOException>(() => useCase.Execute(expected)); exception.Should().NotBeNull(); }
public void Execute(MovementRequest request) { var response = new MovementResponse { Info = $"Order already exists: {request.Info}", Quantity = request.Quantity, Source = request.Source, Status = AutomationStatus.OrderAlreadyExists, Target = request.Target, TargetCompartment = request.TargetCompartment, SourceCompartment = request.SourceCompartment, Ticket = request.Ticket, Timestamp = DateTime.UtcNow }; _sendResponseUseCase.Execute(response); }
public void Execute(MovementRequest request) { var response = new MovementResponse { Info = $"Storage point occupied: {request.Info}", Quantity = request.Quantity, Source = request.Source, Status = AutomationStatus.InsertionFailed, Target = request.Target, TargetCompartment = request.TargetCompartment, SourceCompartment = request.SourceCompartment, Ticket = request.Ticket, Timestamp = DateTime.UtcNow }; _sendResponseUseCase.Execute(response); }
public void Execute(MovementRequest request) { var response = new MovementResponse { Info = $"Wrong part count: {request.Info}", Quantity = request.Quantity, Source = request.Source, Status = AutomationStatus.WrongPartCount, Target = request.Target, TargetCompartment = request.TargetCompartment, SourceCompartment = request.SourceCompartment, Ticket = request.Ticket, Timestamp = DateTime.UtcNow }; _sendResponseUseCase.Execute(response); }
public void ReceivingResponseEventShouldAddResponse() { var eventAggregator = new EventAggregator(); var response = new MovementResponse(); var responseEvent = eventAggregator.GetEvent <PubSubEvent <MovementResponseEvent> >(); var viewModel = new MovementResponseListViewModel(eventAggregator); responseEvent.Publish(new MovementResponseEvent { Response = response }); viewModel.Responses.Should().HaveCount(1); }
public void ConstructorForDeletionSucceededShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Deletion succeeded"; var response = new MovementResponse() { Status = AutomationStatus.DeletionSucceeded }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForInsertFailedShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Insertion failed"; var response = new MovementResponse() { Status = AutomationStatus.InsertionFailed }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForTargetOrSourceNotFoundShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Target or source not found"; var response = new MovementResponse() { Status = AutomationStatus.InvalidOrderTargetSourceNotFound }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForShippedNotAllItemsShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Shipped not all items"; var response = new MovementResponse() { Status = AutomationStatus.ShippedNotAllItems }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForWrongPartCountShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Wrong part count"; var response = new MovementResponse() { Status = AutomationStatus.WrongPartCount }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForOrderAlreadyExistShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Order already exists"; var response = new MovementResponse() { Status = AutomationStatus.OrderAlreadyExists }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ConstructorForCountIsZeroShouldSetStatus() { var expectedData = new MovementData(); var expectedStatus = $"Count is zero"; var response = new MovementResponse() { Status = AutomationStatus.CountIsZero }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Status.Should().Be(expectedStatus); }
public void ExecuteShouldWriteResponseFile() { var eventAggregator = new Mock <IEventAggregator>(); var responseEvent = new Mock <PubSubEvent <MovementResponseEvent> >(); eventAggregator.Setup(ea => ea.GetEvent <PubSubEvent <MovementResponseEvent> >()).Returns(responseEvent.Object); var responsePath = $"./responsePath"; var responseFile = $"{responsePath}/MovementResponse_V.xml"; var expectedTicket = Guid.NewGuid(); var expectedTimestamp = DateTime.UtcNow; var expected = new MovementResponse() { Info = "info", Quantity = 2, Source = "source", Target = "target", Status = AutomationStatus.InsertionSucceeded, Ticket = expectedTicket, Timestamp = expectedTimestamp, SourceCompartment = "2", TargetCompartment = "3", }; expected.Data.Add(new MovementData { Barcode = "barcode", Index = "2" }); PrepareResponseDirectory(responsePath); var config = new Mock <IStorageSimulatorConfig>(); config.Setup(c => c.CommunicationPath).Returns(responsePath); ISendResponseUseCase useCase = new SendResponseUseCase(config.Object, eventAggregator.Object); useCase.Execute(expected); File.Exists(responseFile).Should().BeTrue(); var xmlSerializer = new XmlSerializer(typeof(MovementResponse)); using var reader = new FileStream(responseFile, FileMode.Open); var response = (MovementResponse)xmlSerializer.Deserialize(reader); response.Info.Should().Be("info"); response.Quantity.Should().Be(2); response.Source.Should().Be("source"); response.Target.Should().Be("target"); response.Status.Should().Be(AutomationStatus.InsertionSucceeded); response.Ticket.Should().Be(expectedTicket); response.TimestampString.Should().Be(expectedTimestamp.ToString("dd.MM.yyyy hh:mm:ss")); response.SourceCompartment.Should().Be("2"); response.TargetCompartment.Should().Be("3"); responseEvent.Verify(e => e.Publish(It.IsAny <MovementResponseEvent>())); }
public void ConstructorShouldSetProperties() { var expectedData = new MovementData(); expectedData.Barcode = "expected Barcode"; expectedData.Index = "1"; var expectedSource = "expected source"; var expectedInfo = "expected info"; var expectedTargetShelf = "expected target shelf"; var expectedTarget = "expected target"; var expectedSourceShelf = "expected source shelf"; var expectedQuantity = 2; var expectedStatus = $"Insertion succeeded"; var expectedTicket = Guid.NewGuid(); var response = new MovementResponse() { Info = expectedInfo, Quantity = expectedQuantity, Source = expectedSource, SourceCompartment = expectedSourceShelf, Target = expectedTarget, TargetCompartment = expectedTargetShelf, Ticket = expectedTicket, Timestamp = DateTime.UtcNow, Status = AutomationStatus.InsertionSucceeded }; response.Data.Add(expectedData); var viewModel = new MovementResponseViewModel(response); viewModel.Name.Should().Be(expectedInfo); viewModel.Source.Should().Be(expectedSource); viewModel.SourceShelf.Should().Be(expectedSourceShelf); viewModel.Target.Should().Be(expectedTarget); viewModel.TargetShelf.Should().Be(expectedTargetShelf); viewModel.Quantity.Should().Be(expectedQuantity); viewModel.Timestamp.Should().BeBefore(DateTime.Now); viewModel.Ticket.Should().Be(expectedTicket); viewModel.Status.Should().Be(expectedStatus); viewModel.Barcode.Should().Be(expectedData.Barcode); viewModel.ToString().Should().Be(viewModel.Name); }
public void NotifyMovement(IGameObject o) { var answer = new MovementResponse(_navGrid, o); _packetHandlerManager.BroadcastPacketVision(o, answer, Channel.CHL_LOW_PRIORITY); }
public MovementResponseViewModel(MovementResponse response) : base(response) { SetStatus(response.Status); }
public void NotifyMovement(GameObject o) { var answer = new MovementResponse(o); _game.PacketHandlerManager.broadcastPacketVision(o, answer, Channel.CHL_LOW_PRIORITY); }