示例#1
0
        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);
        }
示例#2
0
        public void CloseClosesTheTransportSender()
        {
            var transportSender = new ObservableTransportSenderMock();
            var sender          = new EventSender(transportSender, "dummy", new EventSenderOptions());

            sender.Close();

            Assert.That(transportSender.WasCloseCalled, Is.True);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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.");
        }
示例#6
0
        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);
        }