Ejemplo n.º 1
0
        public void TestThatNotExpectedPropertyCallThrow(ConnectionModeSwitch connectionModeSwitch, string property, bool shouldFail)
        {
            var connectionString = $"mongodb://localhost";
            var url = new MongoUrl(connectionString);

            url._connectionModeSwitch(connectionModeSwitch);
            Exception exception;

            switch (property)
            {
            case "connect": exception = Record.Exception(() => url.ConnectionMode); break;

            case "directConnection": exception = Record.Exception(() => url.DirectConnection); break;

            default: throw new Exception($"Unexpected property {property}.");
            }

            if (shouldFail)
            {
                exception.Should().BeOfType <InvalidOperationException>();
            }
            else
            {
                exception.Should().BeNull();
            }
        }