public void AddTwoListenersAndPerformLogSuccessfully() { //Arrange var asyncListener = new AsynchronousImpressionListener(); var listener1 = new TestListener(); var listenerMock2 = new Mock <IImpressionListener>(); asyncListener.AddListener(listener1); asyncListener.AddListener(listenerMock2.Object); //Act asyncListener.Log(new KeyImpression() { feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any" }); Thread.Sleep(1000); //Assert Assert.AreEqual(listener1.list.Count, 1); listenerMock2.Verify(x => x.Log(It.Is <KeyImpression>(p => p.keyName == "date" && p.feature == "test" && p.treatment == "on" && p.time == 10000000 && p.changeNumber == 100 && p.label == "testdate" && p.bucketingKey == "any")), Times.Once()); }
public void AddTwoListenersAndPerformLogSuccessfullyWithOneLongRunningTask() { //Arrange var asyncListener = new AsynchronousImpressionListener(); var listener1 = new TestListener2(); var listener2 = new TestListener(); asyncListener.AddListener(listener1); asyncListener.AddListener(listener2); //Act asyncListener.Log(new KeyImpression() { feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any" }); Thread.Sleep(1000); //Assert Assert.AreEqual(listener2.list.Count, 1); Thread.Sleep(10000); Assert.AreEqual(listener1.list.Count, 1); }