public void constructor_should_initialize_instance() { var result = new CoreServerSession(); result.Id.Should().NotBeNull(); result.LastUsedAt.Should().NotHaveValue(); }
public void WasUsed_should_have_expected_result() { var subject = new CoreServerSession(); subject.WasUsed(); subject.LastUsedAt.Should().BeCloseTo(DateTime.UtcNow); }
public void Dispose_should_do_nothing() { var subject = new CoreServerSession(); subject.Dispose(); subject.WasUsed(); // call some method to assert no ObjectDisposedException is thrown }
public void LastUsedAt_should_return_expected_result_when_WasUsed_has_never_been_called() { var subject = new CoreServerSession(); var result = subject.LastUsedAt; result.Should().NotHaveValue(); }
public void Id_should_return_expected_result() { var subject = new CoreServerSession(); var result = subject.Id; result.Should().NotBeNull(); }
public IClientSessionHandle StartImplicitSession(CancellationToken cancellationToken) { var options = new ClientSessionOptions(); var coreServerSession = new CoreServerSession(); var coreSession = new CoreSession(coreServerSession, options.ToCore(isImplicit: true)); var coreSessionHandle = new CoreSessionHandle(coreSession); return(new ClientSessionHandle(_client, options, coreSessionHandle)); }
public IClientSessionHandle StartImplicitSession(CancellationToken cancellationToken) { var options = new ClientSessionOptions(); var coreServerSession = new CoreServerSession(); var serverSession = new ServerSession(coreServerSession); var session = new ClientSession(_client, options, serverSession, isImplicit: true); var handle = new ClientSessionHandle(session); return(handle); }
public void LastUsedAt_should_return_expected_result_when_WasUsed_has_been_called() { var subject = new CoreServerSession(); subject.WasUsed(); var result = subject.LastUsedAt; result.Should().BeCloseTo(DateTime.UtcNow); }
// private methods private IClientSessionHandle CreateClientSession() { var client = new Mock <IMongoClient>().Object; var options = new ClientSessionOptions(); var coreServerSession = new CoreServerSession(); var serverSession = new ServerSession(coreServerSession); var clientSession = new ClientSession(client, options, serverSession, isImplicit: false); return(new ClientSessionHandle(clientSession)); }
// private methods private IClientSessionHandle CreateClientSession() { var client = new Mock <IMongoClient>().Object; var options = new ClientSessionOptions(); var coreServerSession = new CoreServerSession(); var coreSession = new CoreSession(coreServerSession, options.ToCore()); var coreSessionHandle = new CoreSessionHandle(coreSession); return(new ClientSessionHandle(client, options, coreSessionHandle)); }
public IClientSessionHandle StartImplicitSession(CancellationToken cancellationToken) { var cluster = Mock.Of <ICluster>(); var options = new ClientSessionOptions(); var coreServerSession = new CoreServerSession(); #pragma warning disable CS0618 // Type or member is obsolete var coreSession = new CoreSession(cluster, coreServerSession, options.ToCore(isImplicit: true)); #pragma warning restore CS0618 // Type or member is obsolete var coreSessionHandle = new CoreSessionHandle(coreSession); return(new ClientSessionHandle(_client, options, coreSessionHandle)); }
// private methods private IClientSessionHandle CreateClientSession() { var client = new Mock <IMongoClient>().Object; var options = new ClientSessionOptions(); var cluster = Mock.Of <ICluster>(); var coreServerSession = new CoreServerSession(); #pragma warning disable CS0618 // Type or member is obsolete var coreSession = new CoreSession(cluster, coreServerSession, options.ToCore()); #pragma warning restore CS0618 // Type or member is obsolete var coreSessionHandle = new CoreSessionHandle(coreSession); return(new ClientSessionHandle(client, options, coreSessionHandle)); }
public void Fork_should_return_expected_result() { var coreServerSession = new CoreServerSession(); var options = new ClientSessionOptions(); var coreSession = new CoreSession(coreServerSession, options.ToCore()); var coreSessionHandle = new CoreSessionHandle(coreSession); var subject = CreateSubject(coreSession: coreSessionHandle); coreSessionHandle.ReferenceCount().Should().Be(1); var result = subject.Fork(); result.Client.Should().BeSameAs(subject.Client); result.Options.Should().BeSameAs(subject.Options); result.WrappedCoreSession.Should().NotBeSameAs(subject.WrappedCoreSession); var coreSessionHandle1 = (CoreSessionHandle)subject.WrappedCoreSession; var coreSessionHandle2 = (CoreSessionHandle)result.WrappedCoreSession; coreSessionHandle2.Wrapped.Should().BeSameAs(coreSessionHandle1.Wrapped); coreSessionHandle.ReferenceCount().Should().Be(2); }
public void Fork_should_return_expected_result() { var cluster = Mock.Of <ICluster>(); var coreServerSession = new CoreServerSession(); var options = new ClientSessionOptions(); #pragma warning disable CS0618 // Type or member is obsolete var coreSession = new CoreSession(cluster, coreServerSession, options.ToCore()); #pragma warning restore CS0618 // Type or member is obsolete var coreSessionHandle = new CoreSessionHandle(coreSession); var subject = CreateSubject(coreSession: coreSessionHandle); coreSessionHandle.ReferenceCount().Should().Be(1); var result = subject.Fork(); result.Client.Should().BeSameAs(subject.Client); result.Options.Should().BeSameAs(subject.Options); result.WrappedCoreSession.Should().NotBeSameAs(subject.WrappedCoreSession); var coreSessionHandle1 = (CoreSessionHandle)subject.WrappedCoreSession; var coreSessionHandle2 = (CoreSessionHandle)result.WrappedCoreSession; coreSessionHandle2.Wrapped.Should().BeSameAs(coreSessionHandle1.Wrapped); coreSessionHandle.ReferenceCount().Should().Be(2); }