public void CompleteAddingAnEmptyQueue() { using var q = new ConcurrentBufferedQueue <int, string>(); q.CompleteAdding(); q.IsAddingCompleted.Should().BeTrue(); q.IsCompleted.Should().BeTrue(); }
public void AddAfterCompletionThrowsException() { using var q = new ConcurrentBufferedQueue <int, string>(); q.CompleteAdding(); var addAction = new Action(() => q.Add(1, "Hallo 1")); addAction.Should().Throw <InvalidOperationException>(); }
public void CallTakeAfterCompletingThrowsAnException() { using (var q = new ConcurrentBufferedQueue <int, string>(NullTime.Source)) { var takeAction = new Action(() => { var result = q.Take(); }); q.CompleteAdding(); takeAction.Should().Throw <InvalidOperationException>(); } }
public void CallTakeAfterCompletingThrowsAnException() { using var q = new ConcurrentBufferedQueue <int, string>(); bool?success = null; var takeAction = new Action(() => (success, _, _) = q.Take()); q.CompleteAdding(); takeAction(); success.HasValue.Should().BeTrue(); success.Value.Should().BeFalse(); }
public void CompletingTheBufferWhileTakeIsWaitingThrowsAnException() { using var q = new ConcurrentBufferedQueue <int, string>(); Task.Factory.StartNew(() => { Thread.Sleep(50); // Make sure Take is called before the next line is executed q.CompleteAdding(); }); var(success, _, _) = q.Take(); success.Should().BeFalse(); }
public void AddAfterCompletionThrowsException() { using (var q = new ConcurrentBufferedQueue <int, string>(NullTime.Source)) { q.CompleteAdding(); var addAction = new Action(() => { q.Add(1, "Hallo 1"); }); addAction.ShouldThrow <InvalidOperationException>(); } }
public void CompleteAddingPropertiesWorkAsExpected() { using var q = new ConcurrentBufferedQueue <int, string>(); q.Add(1, "Hallo 1"); q.Add(2, "Hallo 2"); q.CompleteAdding(); q.IsAddingCompleted.Should().BeTrue(); q.IsCompleted.Should().BeFalse(); _ = q.Take(); _ = q.Take(); q.IsCompleted.Should().BeTrue(); }
public void CompletingTheBufferWhileTakeIsWaitingThrowsAnException() { using (var q = new ConcurrentBufferedQueue <int, string>(NullTime.Source)) { Task.Factory.StartNew(() => { Thread.Sleep(50); //Make sure Take is called before the next line is executed q.CompleteAdding(); }); var takeAction = new Action(() => { var result = q.Take(); }); takeAction.Should().Throw <InvalidOperationException>(); } }