예제 #1
0
        public void StatusMessageFromARegisteredComponentReturnsNoOperationIfThereAreNoTasksPending()
        {
            var waitHandle = new AutoResetEvent(false);

            var msg = new StatusMessage
            {
                ComponentId = 5,
                Threads = new List<ThreadStatus> {new ThreadStatus {ProblemType = "dvrp"}}
            };
            var rawMsg = _marshaller.Marshall(new Message[] {msg});

            Message outputMessage = null;
            ProcessedDataCallback c = response =>
            {
                outputMessage = _marshaller.Unmarshall(response)[0];
                waitHandle.Set();
            };
            _processor.StartProcessing();
            _processor.EnqueueDataToProcess(rawMsg, null, c);

            waitHandle.WaitOne(5000);
            _processor.StopProcessing();

            Assert.IsInstanceOfType(outputMessage, typeof (ErrorMessage));
        }
예제 #2
0
        public void StatusMessageXmlIsProperlySerializedAndDeserialized()
        {
            var ts = new ThreadStatus
            {
                PartialProblemId = 5,
                ProblemInstanceId = 10,
                ProblemType = "Dvrp",
                State = ThreadStatus.ThreadState.Busy,
                TimeInThisState = 50
            };

            var message = new StatusMessage
            {
                ComponentId = 5,
                Threads = new List<ThreadStatus> {ts}
            };

            var serializedMessage = _serializer.Serialize(message);
            var deserializedMessage = _serializer.Deserialize(serializedMessage);

            Assert.IsInstanceOfType(deserializedMessage, typeof (StatusMessage));
        }