public void Constructor_should_initialize_subject()
        {
            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            subject.DatabaseNamespace.DatabaseName.Should().Be(_databaseNamespace.DatabaseName);
            subject.MessageEncoderSettings.Should().BeEquivalentTo(_messageEncoderSettings);
        }
        public async Task ExecuteAsync_should_return_false_when_database_does_not_exist()
        {
            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            var result = await ExecuteOperationAsync(subject);

            result.Should().BeFalse();
        }
        public void Execute_should_return_false_when_database_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().BeFalse();
        }
        public async Task ExecuteAsync_should_return_true_when_database_exists()
        {
            Insert(BsonDocument.Parse("{x:1}")); // ensure database exists

            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            var result = await ExecuteOperationAsync(subject);

            result.Should().BeTrue();
        }
        public void Execute_should_return_true_when_database_exists(
            [Values(false, true)]
            bool async)
        {
            Insert(BsonDocument.Parse("{x:1}")); // ensure database exists

            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);

            result.Should().BeTrue();
        }
        public void Execute_should_return_false_when_database_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check();
            DropDatabase();
            var subject = new DatabaseExistsOperation(_databaseNamespace, _messageEncoderSettings);

            try
            {
                var result = ExecuteOperation(subject, async);

                result.Should().BeFalse();
            }
            finally
            {
                try { DropDatabase(); } catch { }
            }
        }