EvalOperation

We found 10 examples in language CSharp for this search. You will see 60 fragments of code.

        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Theory]
        [ParameterAttributeData]
        public void NoLock_should_work(
            [Values(null, false, true)]
            bool? value)
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            subject.NoLock = value;

            subject.NoLock.Should().Be(value);
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [SkippableTheory]
        [ParameterAttributeData]
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Authentication(false);
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().Be(1.0);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }


        [Fact]
        public void Args_should_work()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var args = new BsonValue[] { 1, 2, 3 };

            subject.Args = args;

            subject.Args.Should().Equal(args);
        }

        [Fact]
        public void constructor_should_throw_when_databaseNamespace_is_null()
        {
            var function = new BsonJavaScript("return 1");

            Action action = () => new EvalOperation(null, function, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void constructor_should_throw_when_function_is_null()
        {
            Action action = () => new EvalOperation(_adminDatabaseNamespace, null, _messageEncoderSettings);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Fact]
        public void CreateCommand_should_return_expected_result()
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);
            var expectedResult = new BsonDocument
            {
                { "$eval", function }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }

        [Theory]
        [ParameterAttributeData]
        public void Execute_should_throw_when_binding_isNull(
            [Values(false, true)]
            bool async)
        {
            var function = "return 1";
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow<ArgumentNullException>();
        }

        [Theory]
        [ParameterAttributeData]
        public void NoLock_should_work(
            [Values(null, false, true)]
            bool? value)
        {
            var function = new BsonJavaScript("return 1");
            var subject = new EvalOperation(_adminDatabaseNamespace, function, _messageEncoderSettings);

            subject.NoLock = value;

            subject.NoLock.Should().Be(value);
        }

MongoDB.Driver.Core.Operations.EvalOperation : IWriteOperation

Constructors :

public EvalOperation(DatabaseNamespace databaseNamespace = , BsonJavaScript function = , MessageEncoderSettings messageEncoderSettings = )

Methods :

public IEnumerable<BsonValue> get_Args()
public Void set_Args(IEnumerable<BsonValue> value = )
public DatabaseNamespace get_DatabaseNamespace()
public BsonJavaScript get_Function()
public Nullable<TimeSpan> get_MaxTime()
public Void set_MaxTime(Nullable<TimeSpan> value = )
public MessageEncoderSettings get_MessageEncoderSettings()
public Nullable<Boolean> get_NoLock()
public Void set_NoLock(Nullable<Boolean> value = )
public BsonValue Execute(IWriteBinding binding = , CancellationToken cancellationToken = )
public Task<BsonValue> ExecuteAsync(IWriteBinding binding = , CancellationToken cancellationToken = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()