Example #1
0
        public void Received_messages_with_the_same_id_should_throw()
        {
            var subject = new AsyncDropbox <int, int>();

            subject.Post(10, 11);
            Action act = () => subject.Post(10, 12);

            act.ShouldThrow <ArgumentException>();
        }
Example #2
0
        public void Receive_async_should_complete_when_message_is_posted()
        {
            var subject = new AsyncDropbox <int, int>();

            var result = subject.ReceiveAsync(10, CancellationToken.None);

            subject.Post(10, 11);

            result.Result.Should().Be(11);
        }
Example #3
0
        public void Receive_async_should_return_a_completed_task_when_then_message_already_exists()
        {
            var subject = new AsyncDropbox <int, int>();

            subject.Post(10, 11);

            var result = subject.ReceiveAsync(10, CancellationToken.None);

            result.Result.Should().Be(11);
        }
Example #4
0
        public async Task Receive_async_should_remove_message_from_dropbox()
        {
            var subject = new AsyncDropbox <int, int>();

            subject.Post(10, 11);

            subject.MessageCount.Should().Be(1);
            var result = await subject.ReceiveAsync(10, CancellationToken.None);

            subject.MessageCount.Should().Be(0);

            result.Should().Be(11);
        }