public void SendRequiresEvents() { var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions()); Assert.That(async() => await sender.SendAsync(null, new EventBatchingOptions()), Throws.ArgumentNullException); }
public void CloseClosesTheTransportSender() { var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions()); sender.Close(); Assert.That(transportSender.WasCloseCalled, Is.True); }
public async Task CloseAsyncClosesTheTransportSender() { var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions()); await sender.CloseAsync(); Assert.That(transportSender.WasCloseCalled, Is.True); }
public void SendAllowsAPartitionHashKey() { var batchingOptions = new EventBatchingOptions { PartitionKey = "testKey" }; var events = new[] { new EventData(new byte[] { 0x44, 0x66, 0x88 }) }; var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions()); Assert.That(async() => await sender.SendAsync(events, batchingOptions), Throws.Nothing); }
public async Task SendWithoutOptionsInvokesTheTransportSender() { var events = Mock.Of <IEnumerable <EventData> >(); var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions()); await sender.SendAsync(events); (var calledWithEvents, var calledWithOptions) = transportSender.SendCalledWithParameters; Assert.That(calledWithEvents, Is.SameAs(events), "The events should be the same instance."); Assert.That(calledWithOptions, Is.Not.Null, "A default set of options should be used."); }
public void SendForASpecificPartitionDoesNotAllowAPartitionHashKey() { var batchingOptions = new EventBatchingOptions { PartitionKey = "testKey" }; var events = new[] { new EventData(new byte[] { 0x44, 0x66, 0x88 }) }; var transportSender = new ObservableTransportSenderMock(); var sender = new EventSender(transportSender, "dummy", new EventSenderOptions { PartitionId = "1" }); Assert.That(async() => await sender.SendAsync(events, batchingOptions), Throws.InvalidOperationException); }