public void GetChannelAsync_should_delegate_to_reference() { var subject = new ChannelSourceHandle(_channelSource); subject.GetChannelAsync(CancellationToken.None); _channelSource.Received().GetChannelAsync(CancellationToken.None); }
public void Session_should_delegate_to_reference() { var subject = new ChannelSourceHandle(_mockChannelSource.Object); var result = subject.Session; _mockChannelSource.Verify(m => m.Session, Times.Once); }
public void GetChannelAsync_should_throw_if_disposed() { var subject = new ChannelSourceHandle(_channelSource); subject.Dispose(); Action act = () => subject.GetChannelAsync(CancellationToken.None); act.ShouldThrow <ObjectDisposedException>(); }
public void Fork_should_throw_if_disposed() { var subject = new ChannelSourceHandle(_channelSource); subject.Dispose(); Action act = () => subject.Fork(); act.ShouldThrow <ObjectDisposedException>(); }
public void Disposing_of_last_handle_should_dispose_of_connectioSource() { var subject = new ChannelSourceHandle(_channelSource); var forked = subject.Fork(); subject.Dispose(); forked.Dispose(); _channelSource.Received().Dispose(); }
public void Disposing_of_last_handle_should_dispose_of_connectioSource() { var subject = new ChannelSourceHandle(_mockChannelSource.Object); var forked = subject.Fork(); subject.Dispose(); forked.Dispose(); _mockChannelSource.Verify(s => s.Dispose(), Times.Once); }
public void Disposing_of_fork_before_disposing_of_subject_hould_not_dispose_of_channelSource() { var subject = new ChannelSourceHandle(_mockChannelSource.Object); var forked = subject.Fork(); forked.Dispose(); _mockChannelSource.Verify(s => s.Dispose(), Times.Never); subject.Dispose(); _mockChannelSource.Verify(s => s.Dispose(), Times.Once); }
public void Disposing_of_fork_before_disposing_of_subject_hould_not_dispose_of_channelSource() { var subject = new ChannelSourceHandle(_channelSource); var forked = subject.Fork(); forked.Dispose(); _channelSource.DidNotReceive().Dispose(); subject.Dispose(); _channelSource.Received().Dispose(); }
public void GetChannel_should_delegate_to_reference( [Values(false, true)] bool async) { var subject = new ChannelSourceHandle(_mockChannelSource.Object); if (async) { subject.GetChannelAsync(CancellationToken.None).GetAwaiter().GetResult(); _mockChannelSource.Verify(s => s.GetChannelAsync(CancellationToken.None), Times.Once); } else { subject.GetChannel(CancellationToken.None); _mockChannelSource.Verify(s => s.GetChannel(CancellationToken.None), Times.Once); } }
public void GetChannel_should_delegate_to_reference( [Values(false, true)] bool async) { var subject = new ChannelSourceHandle(_channelSource); if (async) { subject.GetChannelAsync(CancellationToken.None).GetAwaiter().GetResult(); _channelSource.Received().GetChannelAsync(CancellationToken.None); } else { subject.GetChannel(CancellationToken.None); _channelSource.Received().GetChannel(CancellationToken.None); } }
public void GetChannel_should_throw_if_disposed( [Values(false, true)] bool async) { var subject = new ChannelSourceHandle(_mockChannelSource.Object); subject.Dispose(); Action act; if (async) { act = () => subject.GetChannelAsync(CancellationToken.None).GetAwaiter().GetResult(); } else { act = () => subject.GetChannel(CancellationToken.None); } act.ShouldThrow<ObjectDisposedException>(); }
public void GetChannel_should_throw_if_disposed( [Values(false, true)] bool async) { var subject = new ChannelSourceHandle(_mockChannelSource.Object); subject.Dispose(); Action act; if (async) { act = () => subject.GetChannelAsync(CancellationToken.None).GetAwaiter().GetResult(); } else { act = () => subject.GetChannel(CancellationToken.None); } act.ShouldThrow <ObjectDisposedException>(); }
public static ReferenceCounted <IChannelSource> _reference(this ChannelSourceHandle obj) => (ReferenceCounted <IChannelSource>)Reflector.GetFieldValue(obj, nameof(_reference));
public static ReferenceCounted <IChannelSource> _reference(this ChannelSourceHandle obj) { var fieldInfo = typeof(ChannelSourceHandle).GetField("_reference", BindingFlags.NonPublic | BindingFlags.Instance); return((ReferenceCounted <IChannelSource>)fieldInfo.GetValue(obj)); }
public void Disposing_of_handle_after_fork_should_not_dispose_of_channelSource() { var subject = new ChannelSourceHandle(_mockChannelSource.Object); var forked = subject.Fork(); subject.Dispose(); _mockChannelSource.Verify(s => s.Dispose(), Times.Never); forked.Dispose(); _mockChannelSource.Verify(s => s.Dispose(), Times.Once); }
public void Fork_should_throw_if_disposed() { var subject = new ChannelSourceHandle(_mockChannelSource.Object); subject.Dispose(); Action act = () => subject.Fork(); act.ShouldThrow<ObjectDisposedException>(); }
// private fields public static bool _disposed(this ChannelSourceHandle obj) => (bool)Reflector.GetFieldValue(obj, nameof(_disposed));
/// <summary> /// Checks whether the server is alive (throws an exception if not). /// </summary> public void Ping() { var messageEncoderSettings = GetMessageEncoderSettings(); var operation = new PingOperation(messageEncoderSettings); var server = GetServer(); using (var channelSource = new ChannelSourceHandle(new ServerChannelSource(server))) using (var channelSourceBinding = new ChannelSourceReadWriteBinding(channelSource, ReadPreference.PrimaryPreferred)) { operation.Execute(channelSourceBinding, CancellationToken.None); } }
public void Disposing_of_handle_after_fork_should_not_dispose_of_channelSource() { var subject = new ChannelSourceHandle(_channelSource); var forked = subject.Fork(); subject.Dispose(); _channelSource.DidNotReceive().Dispose(); forked.Dispose(); _channelSource.Received().Dispose(); }