public void Useful_exception_is_thrown_by_GetProviderManifestTokenChecked()
        {
            var fakeConnection = new SqlConnection("Data Source=AnyConnectionString");
            var innerException = new ProviderIncompatibleException();

            var mockProviderServices = new Mock<DbProviderServices>();
            mockProviderServices
                .Protected()
                .Setup("GetDbProviderManifestToken", fakeConnection)
                .Throws(innerException);

            var ex =
                Assert.Throws<ProviderIncompatibleException>(
                    () => mockProviderServices.Object.GetProviderManifestTokenChecked(fakeConnection));
            Assert.Equal(Strings.FailedToGetProviderInformation, ex.Message);
            Assert.Same(innerException, ex.InnerException);
        }
Beispiel #2
0
 internal static ProviderIncompatibleException ProviderIncompatible(string message)
 {
     var e = new ProviderIncompatibleException(message);
     return e;
 }
        private void Useful_exception_is_thrown_by_GetProviderManifestTokenChecked_if_bad_connection_string_is_used(
            string connectionString, string expectedMessage)
        {
            var fakeConnection = new SqlConnection(connectionString);
            var innerException = new ProviderIncompatibleException();

            var mockProviderServices = new Mock<DbProviderServices>();
            mockProviderServices
                .Protected()
                .Setup("GetDbProviderManifestToken", fakeConnection)
                .Throws(innerException);

            var ex =
                Assert.Throws<ProviderIncompatibleException>(
                    () => mockProviderServices.Object.GetProviderManifestTokenChecked(fakeConnection));
            Assert.Equal(expectedMessage, ex.Message);
            Assert.Same(innerException, ex.InnerException);
        }