Exemplo n.º 1
0
        public void ResultHandler_WaitForResult_ReactivateWaitHandle()
        {
            var resultHandler = new ResultHandler();
            var waitHandle = resultHandler.RegisterWaitHandler(ResultFilterFactory.CreateConnectResultFilter());

            var waitTask = resultHandler.WaitForResult(waitHandle);

            var connected = new Connected() { Session = "TestSession" };
            var returnedObject = new ReturnedObject(connected.MessageType, JObject.FromObject(connected),
                JsonConvert.SerializeObject(connected));

            resultHandler.AddResult(returnedObject);

            waitTask.Wait();

            Assert.AreEqual(returnedObject, waitTask.Result);

            PCLTesting.ExceptionAssert.Throws<InvalidOperationException>(() => resultHandler.WaitForResult(waitHandle));
        }
Exemplo n.º 2
0
        public void ResultHandler_WaitForResult_DuplicateWaitHandle()
        {
            var resultHandler = new ResultHandler();
            var waitHandle = resultHandler.RegisterWaitHandler(ResultFilterFactory.CreateConnectResultFilter());

            var waitTask = resultHandler.WaitForResult(waitHandle);
            var secondWaitTask = resultHandler.WaitForResult(waitHandle);

            var connected = new Connected() { Session = "TestSession" };
            var returnedObject = new ReturnedObject(connected.MessageType, JObject.FromObject(connected),
                JsonConvert.SerializeObject(connected));

            resultHandler.AddResult(returnedObject);

            waitTask.Wait();
            secondWaitTask.Wait();

            Assert.AreEqual(returnedObject, waitTask.Result);
            Assert.AreEqual(returnedObject, secondWaitTask.Result);
        }