public void AddListenerAndPerformLogSuccessfully() { //Arrange _asyncListener.AddListener(_listenerMock.Object); //Act _asyncListener.Log(new Event { key = "Key1", eventTypeId = "testEventType", trafficTypeName = "testTrafficType", timestamp = 7000, value = 12.34 }); Thread.Sleep(1000); //Assert _listenerMock.Verify(x => x.Log(It.Is <Event>(e => e.key == "Key1" && e.eventTypeId == "testEventType" && e.trafficTypeName == "testTrafficType" && e.timestamp == 7000 && e.value == 12.34))); }
public void AddListenerAndPerformLogSuccessfully() { _asyncListener.AddListener(_listenerMock.Object); //Act _asyncListener.Log(new KeyImpression() { feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any" }); Thread.Sleep(1000); //Assert _listenerMock.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"))); }
public void AddTwoListenersAndPerformLogSuccessfully() { //Arrange var logger = new Mock <ILog>(); var asyncListener = new AsynchronousListener <KeyImpression>(logger.Object); var listener1 = new TestListener(); var listenerMock2 = new Mock <IListener <KeyImpression> >(); 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 logger = new Mock <ILog>(); var asyncListener = new AsynchronousListener <KeyImpression>(logger.Object); 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); }