public void UnRegisterObserverTest() { TestLauncherActor.Test(() => { ObservableActor <string> act = new ObservableActor <string>(); TestObserver observer = new TestObserver(); act.RegisterObserver(observer); string testString = string.Format(CultureInfo.InvariantCulture, "Test {0}", observer.Tag); act.SendMessage(testString); string result = observer.GetData(); Assert.AreEqual(result, string.Format(CultureInfo.InvariantCulture, "Test {0}", observer.Tag)); act.UnregisterObserver(observer); act.SendMessage(testString); result = observer.GetDataInTime(1000); Assert.AreEqual(result, null); }); }
public void RegisterObserverTest() { TestLauncherActor.Test(() => { ObservableActor <string> act = new ObservableActor <string>(); TestObserver observer = new TestObserver(); act.RegisterObserver(observer); string testString = string.Format("Test {0}", observer.Tag); act.SendMessage(testString); string result = observer.GetData(); Assert.AreEqual(result, string.Format("Test {0}", observer.Tag)); }); }
public void PublishDataTest() { TestLauncherActor.Test(() => { ObservableActor <string> act = new ObservableActor <string>(); TestObserver observer1 = new TestObserver(); act.RegisterObserver(observer1); TestObserver observer2 = new TestObserver(); act.RegisterObserver(observer2); string testString = string.Format("Test {0}", observer1.Tag); act.SendMessage(testString); string result1 = observer1.GetData(); Assert.AreEqual(result1, string.Format("Test {0}", observer1.Tag)); string result2 = observer2.GetData(); Assert.AreEqual(result2, string.Format("Test {0}", observer2.Tag)); }); }
public void PublishDataTest() { TestLauncherActor.Test(() => { ObservableActor <string> observableActor = new ObservableActor <string>(); TestObserver observer1 = new TestObserver(); observableActor.RegisterObserver(observer1); TestObserver observer2 = new TestObserver(); observableActor.RegisterObserver(observer2); string testString = $"Test {observer1.Tag}"; observableActor.SendMessage(testString); string result1 = observer1.GetData(); Assert.AreEqual(result1, $"Test {observer1.Tag}"); string result2 = observer2.GetData(); Assert.AreEqual(result2, $"Test {observer2.Tag}"); }); }