Exemplo n.º 1
0
        public void CreateCommand_should_return_expected_result(
            [Values("a", "b")]
            string viewName)
        {
            var subject = new CreateViewOperation(_databaseNamespace, viewName, _collectionNamespace.CollectionName, _pipeline, _messageEncoderSettings);

            var result = subject.CreateCommand(Feature.Views.FirstSupportedVersion);

            var expectedResult = new BsonDocument
            {
                { "create", viewName },
                { "viewOn", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(_pipeline) }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result(
            [Values("a", "b")]
            string viewName)
        {
            var subject = new CreateViewOperation(_databaseNamespace, viewName, _collectionNamespace.CollectionName, _pipeline, _messageEncoderSettings);
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", viewName },
                { "viewOn", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(_pipeline) }
            };

            result.Should().Be(expectedResult);
        }
Exemplo n.º 3
0
        public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
            [Values(null, 1, 2)]
            int?w)
        {
            var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
            var subject      = new CreateViewOperation(_databaseNamespace, _viewName, _collectionNamespace.CollectionName, _pipeline, _messageEncoderSettings)
            {
                WriteConcern = writeConcern
            };

            var result = subject.CreateCommand(Feature.Views.FirstSupportedVersion);

            var expectedResult = new BsonDocument
            {
                { "create", _viewName },
                { "viewOn", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(_pipeline) },
                { "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null }
            };

            result.Should().Be(expectedResult);
        }
Exemplo n.º 4
0
        public void CreateCommand_should_return_expected_result_when_Collation_is_set(
            [Values(null, "en_US", "fr_CA")]
            string locale)
        {
            var collation = locale == null ? null : new Collation(locale);
            var subject   = new CreateViewOperation(_databaseNamespace, _viewName, _collectionNamespace.CollectionName, _pipeline, _messageEncoderSettings)
            {
                Collation = collation
            };

            var result = subject.CreateCommand(Feature.Views.FirstSupportedVersion);

            var expectedResult = new BsonDocument
            {
                { "create", _viewName },
                { "viewOn", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(_pipeline) },
                { "collation", () => collation.ToBsonDocument(), collation != null }
            };

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