// constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="CoreSession" /> class.
 /// </summary>
 /// <param name="serverSession">The server session.</param>
 /// <param name="options">The options.</param>
 public CoreSession(
     ICoreServerSession serverSession,
     CoreSessionOptions options)
 {
     _serverSession = Ensure.IsNotNull(serverSession, nameof(serverSession));
     _options       = Ensure.IsNotNull(options, nameof(options));
 }
        public void constructor_should_initialize_instance_with_default_values()
        {
            var result = new CoreSessionOptions();

            result.IsCausallyConsistent.Should().BeFalse();
            result.IsImplicit.Should().BeFalse();
        }
 private CoreSession(
     ICluster cluster,
     CoreSessionOptions options)
 {
     _cluster = Ensure.IsNotNull(cluster, nameof(cluster));
     _options = Ensure.IsNotNull(options, nameof(options));
 }
Ejemplo n.º 4
0
        public void AutoStartTransaction_should_return_expected_result(
            [Values(false, true)] bool value)
        {
            var subject = new CoreSessionOptions(autoStartTransaction: value);

            var result = subject.AutoStartTransaction;

            result.Should().Be(value);
        }
Ejemplo n.º 5
0
        public void IsCausallyConsistent_should_return_expected_result(
            [Values(false, true)] bool value)
        {
            var subject = new CoreSessionOptions(isCausallyConsistent: value);

            var result = subject.IsCausallyConsistent;

            result.Should().Be(value);
        }
 // private methods
 private CoreSession CreateSubject(
     ICluster cluster = null,
     ICoreServerSession serverSession = null,
     CoreSessionOptions options       = null)
 {
     serverSession = serverSession ?? Mock.Of <ICoreServerSession>();
     options       = options ?? new CoreSessionOptions();
     return(new CoreSession(serverSession, options));
 }
 internal CoreSession(
     ICluster cluster,
     ICoreServerSessionPool serverSessionPool,
     CoreSessionOptions options)
     : this(cluster, options)
 {
     Ensure.IsNotNull(serverSessionPool, nameof(serverSessionPool));
     _serverSession = new Lazy <ICoreServerSession>(() => serverSessionPool.AcquireSession());
 }
 public CoreSession(
     ICluster cluster,
     ICoreServerSession serverSession,
     CoreSessionOptions options)
     : this(cluster, options : options)
 {
     Ensure.IsNotNull(serverSession, nameof(serverSession));
     _serverSession = new Lazy <ICoreServerSession>(() => serverSession);
 }
Ejemplo n.º 9
0
        public void IsImplicit_should_return_expected_result(
            [Values(false, true)] bool value)
        {
            var subject = new CoreSessionOptions(isImplicit: value);

            var result = subject.IsImplicit;

            result.Should().Be(value);
        }
Ejemplo n.º 10
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="CoreSession" /> class.
 /// </summary>
 /// <param name="cluster">The cluster.</param>
 /// <param name="serverSession">The server session.</param>
 /// <param name="options">The options.</param>
 public CoreSession(
     ICluster cluster,
     ICoreServerSession serverSession,
     CoreSessionOptions options)
 {
     _cluster       = Ensure.IsNotNull(cluster, nameof(cluster));
     _serverSession = Ensure.IsNotNull(serverSession, nameof(serverSession));
     _options       = Ensure.IsNotNull(options, nameof(options));
 }
Ejemplo n.º 11
0
 private CoreSession CreateSubject(
     ICluster cluster = null,
     ICoreServerSession serverSession = null,
     CoreSessionOptions options       = null)
 {
     cluster       = cluster ?? CreateMockReplicaSetCluster();
     serverSession = serverSession ?? Mock.Of <ICoreServerSession>();
     options       = options ?? new CoreSessionOptions();
     return(new CoreSession(cluster, serverSession, options));
 }
Ejemplo n.º 12
0
        public void DefaultTransactionOptions_should_return_expected_result(
            [Values(false, true)] bool nullDefaultTransactionOptions)
        {
            var defaultTransactionOptions = nullDefaultTransactionOptions ? null : new TransactionOptions();
            var subject = new CoreSessionOptions(defaultTransactionOptions: defaultTransactionOptions);

            var result = subject.DefaultTransactionOptions;

            result.Should().BeSameAs(defaultTransactionOptions);
        }
        public void constructor_should_initialize_instance()
        {
            var serverSession = Mock.Of <ICoreServerSession>();
            var options       = new CoreSessionOptions();

            var result = new CoreSession(serverSession, options);

            result.Options.Should().BeSameAs(options);
            result.ServerSession.Should().BeSameAs(serverSession);
            result._disposed().Should().BeFalse();
        }
        public void constructor_should_initialize_instance(
            [Values(false, true)] bool isCausallyConsistent,
            [Values(false, true)] bool isImplicit)
        {
            var result = new CoreSessionOptions(
                isCausallyConsistent: isCausallyConsistent,
                isImplicit: isImplicit);

            result.IsCausallyConsistent.Should().Be(isCausallyConsistent);
            result.IsImplicit.Should().Be(isImplicit);
        }
Ejemplo n.º 15
0
        private CoreSession CreateSubject(
            ICluster cluster = null,
            ICoreServerSession serverSession = null,
            CoreSessionOptions options       = null)
        {
            cluster       = cluster ?? CreateMockReplicaSetCluster();
            serverSession = serverSession ?? Mock.Of <ICoreServerSession>();
            options       = options ?? new CoreSessionOptions();
#pragma warning disable CS0618 // Type or member is obsolete
            return(new CoreSession(cluster, serverSession, options));

#pragma warning restore CS0618 // Type or member is obsolete
        }
Ejemplo n.º 16
0
        public void constructor_should_initialize_instance()
        {
            var cluster       = Mock.Of <ICluster>();
            var serverSession = Mock.Of <ICoreServerSession>();
            var options       = new CoreSessionOptions();

            var result = new CoreSession(cluster, serverSession, options);

            result.Cluster.Should().BeSameAs(cluster);
            result.CurrentTransaction.Should().BeNull();
            result.IsInTransaction.Should().BeFalse();
            result.Options.Should().BeSameAs(options);
            result.ServerSession.Should().BeSameAs(serverSession);
            result._disposed().Should().BeFalse();
        }
        public void constructor_should_initialize_instance(
            [Values(false, true)] bool nullDefaultTransactionOptions,
            [Values(false, true)] bool isCausallyConsistent,
            [Values(false, true)] bool isImplicit)
        {
            var defaultTransactionOptions = nullDefaultTransactionOptions ? null : new TransactionOptions();

            var result = new CoreSessionOptions(
                defaultTransactionOptions: defaultTransactionOptions,
                isCausallyConsistent: isCausallyConsistent,
                isImplicit: isImplicit);

            result.DefaultTransactionOptions.Should().BeSameAs(defaultTransactionOptions);
            result.IsCausallyConsistent.Should().Be(isCausallyConsistent);
            result.IsImplicit.Should().Be(isImplicit);
        }
Ejemplo n.º 18
0
        public void constructor_should_initialize_instance()
        {
            var cluster       = Mock.Of <ICluster>();
            var serverSession = Mock.Of <ICoreServerSession>();
            var options       = new CoreSessionOptions();

#pragma warning disable CS0618 // Type or member is obsolete
            var result = new CoreSession(cluster, serverSession, options);
#pragma warning restore CS0618 // Type or member is obsolete

            result.Cluster.Should().BeSameAs(cluster);
            result.CurrentTransaction.Should().BeNull();
            result.IsInTransaction.Should().BeFalse();
            result.Options.Should().BeSameAs(options);
            result.ServerSession.Should().BeSameAs(serverSession);
            result._disposed().Should().BeFalse();
            result._isCommitTransactionInProgress().Should().BeFalse();
        }