public async Task OnMessageArrived() { var data = Guid.NewGuid().ToString(); var msg = new BrokeredMessage(data) { ContentType = data.GetType().ToString(), }; var queue = Substitute.For<IBusQueueReciever>(); var handler = Substitute.For<IBusEventHandler<string>>(); handler.Process(data).Returns(Task.FromResult(true)); var events = new BusEvents<string>(queue, handler); await events.OnMessageArrived(msg); handler.Received().Process(data); }
public async Task OnMessageArrived() { var data = Guid.NewGuid().ToString(); var msg = new BrokeredMessage(data) { ContentType = data.GetType().ToString(), }; var queue = Substitute.For <IBusMessageReciever>(); var handler = Substitute.For <IBusEventHandler <string> >(); handler.Process(data).Returns(Task.FromResult(true)); var events = new BusEvents <string>(queue, handler); await events.OnMessageArrived(msg); await handler.Received().Process(data); }
public async Task OnMessageArrived() { var formatter = new BinaryFormatter(); using (var stream = new MemoryStream()) { var data = Guid.NewGuid(); formatter.Serialize(stream, data); var msg = new Message(stream.ToArray()); var queue = Substitute.For <IBusReciever>(); var handler = Substitute.For <IBusEventHandler <Guid> >(); handler.Process(data).Returns(Task.FromResult(true)); var ct = new CancellationToken(); var events = new BusEvents <Guid>(queue, handler); await events.OnMessageArrived(msg, ct); await handler.Received().Process(data); } }