public void ReceivedMessageEventSequence() { var sut = new ServiceEvents(); var callbackCalled = false; var message = new ReceivedMessage { EventID = Guid.NewGuid(), MessageHandler = StringExtension.RandomString(), MessageType = StringExtension.RandomString(), Topic = StringExtension.RandomString() }; sut.ReceivedMessageEventSequence.Subscribe(i => { Assert.Same(i, message); callbackCalled = true; }); sut.AddReceivedMessageEvent(message); Assert.True(callbackCalled); }
public void ReceivedMessageEventSequence_10() { var sut = new ServiceEvents(); List<ReceivedMessage> events = new List<ReceivedMessage>(); var elements = (10).Times<ReceivedMessage>(new Func<ReceivedMessage>(() => { return new ReceivedMessage { EventID = Guid.NewGuid(), MessageHandler = StringExtension.RandomString(), MessageType = StringExtension.RandomString(), Topic = StringExtension.RandomString() }; })); events.AddRange(elements); events.ForEach(e => sut.AddReceivedMessageEvent(e)); sut.ReceivedMessageEventSequence.Subscribe(i => { Assert.True(events.Contains(i)); events.Remove(i); }); Assert.Empty(events); }