public when_calling_publish()
        {
            this.partitionKey = Guid.NewGuid().ToString();
            this.version = "0001";
            string rowKey = "Unpublished_" + version;
            this.testEvent = Mock.Of<IEventRecord>(x =>
                x.PartitionKey == partitionKey
                && x.RowKey == rowKey
                && x.TypeName == "TestEventType"
                && x.SourceId == "TestId"
                && x.SourceType == "TestSourceType"
                && x.Payload == "serialized event"
                && x.CorrelationId == "correlation"
                && x.AssemblyName == "Assembly"
                && x.Namespace == "Namespace"
                && x.FullName == "Namespace.TestEventType");
            this.queue = new Mock<IPendingEventsQueue>();
            queue.Setup(x => x.GetPendingAsync(partitionKey, It.IsAny<Action<IEnumerable<IEventRecord>, bool>>(), It.IsAny<Action<Exception>>()))
                .Callback<string, Action<IEnumerable<IEventRecord>, bool>, Action<Exception>>((key, success, error) => success(new[] { testEvent }, false));
            this.sender = new MessageSenderMock();
            var sut = new EventStoreBusPublisher(sender, queue.Object, new MockEventStoreBusPublisherInstrumentation());
            var cancellationTokenSource = new CancellationTokenSource();
            sut.Start(cancellationTokenSource.Token);

            sut.SendAsync(partitionKey, 0);

            Assert.True(sender.SendSignal.WaitOne(3000));
            cancellationTokenSource.Cancel();
        }
        public when_calling_publish()
        {
            this.partitionKey = Guid.NewGuid().ToString();
            this.version = "0001";
            string rowKey = "Unpublished_" + version;
            this.testEvent = Mock.Of<IEventRecord>(x =>
                x.PartitionKey == partitionKey
                && x.RowKey == rowKey
                && x.TypeName == "TestEventType"
                && x.SourceId == "TestId"
                && x.SourceType == "TestSourceType"
                && x.Payload == "serialized event"
                && x.AssemblyName == "Assembly"
                && x.Namespace == "Namespace"
                && x.FullName == "Namespace.TestEventType");
            this.queue = new Mock<IPendingEventsQueue>();
            queue.Setup(x => x.GetPending(partitionKey)).Returns(new[] { testEvent });
            this.sender = new MessageSenderMock();
            var sut = new EventStoreBusPublisher(sender, queue.Object);
            var cancellationTokenSource = new CancellationTokenSource();
            sut.Start(cancellationTokenSource.Token);

            sut.SendAsync(partitionKey);

            Assert.True(sender.ResetEvent.WaitOne(3000));
            cancellationTokenSource.Cancel();
        }