示例#1
0
 public void Add_Throws_Error_When_Called_After_Dispose()
 {
     using (var instance = new PpcBuffer <object>(ConcurrentBuffer.Unbounded, CancellationToken.None))
     {
         instance.Dispose();
         Assert.Throws <NullReferenceException>(() => instance.Add(new object(), CancellationToken.None));
     }
 }
示例#2
0
 public void TryGet_Throws_Error_After_Dispose()
 {
     using (var instance = new PpcBuffer <object>(ConcurrentBuffer.Unbounded, CancellationToken.None))
     {
         instance.Dispose();
         Assert.Throws <NullReferenceException>(() =>
                                                instance.TryGet(Timeout.Infinite, CancellationToken.None, out var _));
     }
 }
示例#3
0
        public async Task Add_Throws_Error_When_Called_After_Dispose()
        {
            var instance = new PpcBuffer <object>(ConcurrentBuffer.Unbounded, CancellationToken.None);

#if !NETFRAMEWORK
            await instance.DisposeAsync().ConfigureAwait(false);
#else
            instance.Dispose();
#endif
            Assert.Throws <NullReferenceException>(() => instance.Add(new object(), CancellationToken.None));

            await Task.CompletedTask;
        }
示例#4
0
        public async Task TryGet_Throws_Error_After_Dispose()
        {
            var instance = new PpcBuffer <object>(ConcurrentBuffer.Unbounded, CancellationToken.None);

#if !NETFRAMEWORK && !NETCOREAPP2_2
            await using (instance.ConfigureAwait(false))
#else
            using (instance)
#endif
            {
                instance.Dispose();
                Assert.Throws <NullReferenceException>(() =>
                                                       instance.TryGet(Timeout.Infinite, CancellationToken.None, out _));
            }

            await Task.CompletedTask;
        }