コード例 #1
0
        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");
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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>()));
        }
コード例 #15
0
        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);
        }
コード例 #16
0
ファイル: PacketNotifier.cs プロジェクト: agentran/GameServer
        public void NotifyMovement(IGameObject o)
        {
            var answer = new MovementResponse(_navGrid, o);

            _packetHandlerManager.BroadcastPacketVision(o, answer, Channel.CHL_LOW_PRIORITY);
        }
コード例 #17
0
 public MovementResponseViewModel(MovementResponse response) : base(response)
 {
     SetStatus(response.Status);
 }
コード例 #18
0
ファイル: PacketNotifier.cs プロジェクト: Kaap0/GameServer
        public void NotifyMovement(GameObject o)
        {
            var answer = new MovementResponse(o);

            _game.PacketHandlerManager.broadcastPacketVision(o, answer, Channel.CHL_LOW_PRIORITY);
        }