public IClientSessionHandle StartImplicitSession(CancellationToken cancellationToken)
        {
            var options       = new ClientSessionOptions();
            var serverSession = new ServerSession();
            var session       = new ClientSession(_client, options, serverSession, isImplicit: true);
            var handle        = new ClientSessionHandle(session);

            return(handle);
        }
예제 #2
0
        public void constructor_with_reference_counted_session_should_initialize_instance()
        {
            var session          = new Mock <IClientSession>().Object;
            var referenceCounted = new ReferenceCountedClientSession(session);

            var subject = new ClientSessionHandle(referenceCounted);

            subject.Wrapped.Should().BeSameAs(referenceCounted);
        }
예제 #3
0
        public void constructor_with_client_session_should_initialize_instance()
        {
            var session = new Mock <IClientSession>().Object;

            var subject = new ClientSessionHandle(session);

            subject.IsDisposed().Should().BeFalse();
            subject._ownsWrapped().Should().BeFalse();
            var referenceCounted = subject.Wrapped.Should().BeOfType <ReferenceCountedClientSession>().Subject;

            referenceCounted.Wrapped.Should().BeSameAs(session);
            referenceCounted._referenceCount().Should().Be(1);
            referenceCounted._ownsWrapped().Should().BeFalse();
        }
예제 #4
0
        public void constructor_should_initialize_instance()
        {
            var client      = Mock.Of <IMongoClient>();
            var options     = new ClientSessionOptions();
            var coreSession = CreateCoreSession();

            var result = new ClientSessionHandle(client, options, coreSession);

            result.Client.Should().BeSameAs(client);
            result.Options.Should().BeSameAs(options);
            result.WrappedCoreSession.Should().BeSameAs(coreSession);
            result._disposed().Should().BeFalse();

            var serverSession = result.ServerSession.Should().BeOfType <ServerSession>().Subject;

            serverSession._coreServerSession().Should().BeSameAs(coreSession.ServerSession);
        }
예제 #5
0
 public static IServerSession _serverSession(this ClientSessionHandle obj) => (IServerSession)Reflector.GetFieldValue(obj, nameof(_serverSession));
예제 #6
0
 public static bool _disposed(this ClientSessionHandle obj) => (bool)Reflector.GetFieldValue(obj, nameof(_disposed));
예제 #7
0
 private void SetupTransactionState(ClientSessionHandle clientSession, bool isTransactionInProgress)
 {
     clientSession.WrappedCoreSession.CurrentTransaction.SetState(isTransactionInProgress ? CoreTransactionState.InProgress : CoreTransactionState.Aborted);
 }
예제 #8
0
        public static IServerSession _serverSession(this ClientSessionHandle obj)
        {
            var fieldInfo = typeof(ClientSessionHandle).GetField("_serverSession", BindingFlags.NonPublic | BindingFlags.Instance);

            return((IServerSession)fieldInfo.GetValue(obj));
        }
예제 #9
0
        public static bool _disposed(this ClientSessionHandle obj)
        {
            var fieldInfo = typeof(ClientSessionHandle).GetField("_disposed", BindingFlags.NonPublic | BindingFlags.Instance);

            return((bool)fieldInfo.GetValue(obj));
        }