public void Receive_async_should_return_an_uncompleted_task_when_the_message_does_not_exists() { var subject = new AsyncDropbox <int, int>(); var result = subject.ReceiveAsync(10, CancellationToken.None); result.IsCompleted.Should().BeFalse(); }
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>(); }
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); }
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); }
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); }
public void RemoveAllAwaiters_should_return_the_right_number_of_awaiters(int n) { var subject = new AsyncDropbox <int, int>(); for (var i = 0; i < n; i++) { subject.ReceiveAsync(i, CancellationToken.None); } subject.AwaiterCount.Should().Be(n); var awaiters = subject.RemoveAllAwaiters(); awaiters.Count().Should().Be(n); subject.AwaiterCount.Should().Be(0); }