/// <summary> /// This test often succeeds standalone but fails in a group test. /// Could be a timing / load problem /// </summary> //[TestMethod] public void IOIOHandlerObservableTest_NoWaitSingleThreaded() { IOIOHandlerObservableNoWait notifier = new IOIOHandlerObservableNoWait(); UartFromObserver fromObsv = new UartFromObserver(); UartFromPolyObserver dataFromObsv = new UartFromPolyObserver(); notifier.Subscribe(fromObsv); notifier.Subscribe(dataFromObsv); notifier.HandleMessage(new UartDataFrom(0, 0, null)); notifier.HandleMessage(new UartCloseFrom(0)); notifier.HandleMessage(new UartOpenFrom(0)); System.Threading.Thread.Sleep(20); Assert.AreEqual(3, fromObsv.count); Assert.AreEqual(1, dataFromObsv.countData); Assert.AreEqual(1, dataFromObsv.countOpen); Assert.AreEqual(1, dataFromObsv.countClose); Assert.IsTrue(fromObsv.managedThreads.SetEquals(dataFromObsv.managedThreads)); }
/// <summary> /// This test often succeeds standalone but fails in a group test. /// Could be a timing / load problem /// </summary> public void IOIOHandlerObservableTest_NoWaitParallel() { IOIOHandlerObservableNoWaitParallel notifier = new IOIOHandlerObservableNoWaitParallel(); UartFromObserver fromObsv = new UartFromObserver(); UartFromPolyObserver dataFromObsv = new UartFromPolyObserver(); notifier.Subscribe(fromObsv); notifier.Subscribe(dataFromObsv); notifier.HandleMessage(new UartDataFrom(0, 0, null)); notifier.HandleMessage(new UartCloseFrom(0)); notifier.HandleMessage(new UartOpenFrom(0)); // have to wait some time for the asynch notifications to be received System.Threading.Thread.Sleep(20); Assert.AreEqual(3, fromObsv.count); Assert.AreEqual(1, dataFromObsv.countData); Assert.AreEqual(1, dataFromObsv.countOpen); Assert.AreEqual(1, dataFromObsv.countClose); // they could be the same but it is unlikely Assert.IsFalse(fromObsv.managedThreads.SetEquals(dataFromObsv.managedThreads), "This test could sparodically fail based on how threads get managed"); }