コード例 #1
0
 public void GetSqlVersion_returns_correct_version_for_manifest_token()
 {
     Assert.Equal(SqlVersion.Sql8, SqlVersionUtils.GetSqlVersion("2000"));
     Assert.Equal(SqlVersion.Sql9, SqlVersionUtils.GetSqlVersion("2005"));
     Assert.Equal(SqlVersion.Sql10, SqlVersionUtils.GetSqlVersion("2008"));
     Assert.Equal(SqlVersion.Sql11, SqlVersionUtils.GetSqlVersion("2012"));
 }
コード例 #2
0
 public void GetVersionHint_returns_correct_manifest_token_for_version()
 {
     Assert.Equal("2000", SqlVersionUtils.GetVersionHint(SqlVersion.Sql8));
     Assert.Equal("2005", SqlVersionUtils.GetVersionHint(SqlVersion.Sql9));
     Assert.Equal("2008", SqlVersionUtils.GetVersionHint(SqlVersion.Sql10));
     Assert.Equal("2012", SqlVersionUtils.GetVersionHint(SqlVersion.Sql11));
 }
コード例 #3
0
 public void GetVersionHint_returns_correct_manifest_token_for_version()
 {
     Assert.Equal("2000", SqlVersionUtils.GetVersionHint(SqlVersion.Sql8, ServerType.OnPremises));
     Assert.Equal("2005", SqlVersionUtils.GetVersionHint(SqlVersion.Sql9, ServerType.OnPremises));
     Assert.Equal("2008", SqlVersionUtils.GetVersionHint(SqlVersion.Sql10, ServerType.OnPremises));
     Assert.Equal("2012", SqlVersionUtils.GetVersionHint(SqlVersion.Sql11, ServerType.OnPremises));
     Assert.Equal("2012.Azure", SqlVersionUtils.GetVersionHint(SqlVersion.Sql11, ServerType.Cloud));
 }
コード例 #4
0
        // <summary>
        // Initializes a new instance of the <see cref="SqlProviderManifest" /> class.
        // </summary>
        // <param name="manifestToken"> A token used to infer the capabilities of the store. </param>
        public SqlProviderManifest(string manifestToken)
            : base(GetProviderManifest())
        {
            // GetSqlVersion will throw ArgumentException if manifestToken is null, empty, or not recognized.
            _version = SqlVersionUtils.GetSqlVersion(manifestToken);

            Initialize();
        }
コード例 #5
0
            public void GetServerType_returns_OnPremises_for_real_local_test_database()
            {
                using (var context = new RealDatabase())
                {
                    context.Database.CreateIfNotExists();

                    var connection = context.Database.Connection;
                    connection.Open();

                    Assert.Equal(ServerType.OnPremises, SqlVersionUtils.GetServerType(connection));

                    connection.Close();
                }
            }
コード例 #6
0
            public void GetServerType_returns_correct_ServerType_for_real_test_database()
            {
                using (var context = new RealDatabase())
                {
                    context.Database.CreateIfNotExists();

                    var connection = context.Database.Connection;
                    connection.Open();

                    var expectedServerType = DatabaseTestHelpers.IsSqlAzure(connection.ConnectionString) ? ServerType.Cloud : ServerType.OnPremises;
                    Assert.Equal(expectedServerType, SqlVersionUtils.GetServerType(connection));

                    connection.Close();
                }
            }
コード例 #7
0
            public void GetServerType_dispatches_commands_to_interceptors()
            {
                var connection = CreateConnectionForAzureQuery(5).Object;

                var interceptor = new TestReaderInterceptor();

                Interception.AddInterceptor(interceptor);
                try
                {
                    SqlVersionUtils.GetServerType(connection);
                }
                finally
                {
                    Interception.RemoveInterceptor(interceptor);
                }

                Assert.Equal(1, interceptor.Commands.Count);
                Assert.Same(connection.CreateCommand(), interceptor.Commands.Single());
            }
コード例 #8
0
 public void GetServerType_returns_OnPremises_for_server_with_EngineEdtion_not_equal_to_five()
 {
     Assert.Equal(ServerType.OnPremises, SqlVersionUtils.GetServerType(CreateConnectionForAzureQuery(1).Object));
 }
コード例 #9
0
 public void GetVersionHint_throws_for_unknown_version()
 {
     Assert.Equal(
         Strings.UnableToDetermineStoreVersion,
         Assert.Throws <ArgumentException>(() => SqlVersionUtils.GetVersionHint((SqlVersion)120, ServerType.OnPremises)).Message);
 }
コード例 #10
0
 public void GetSqlVersion_throws_for_unknown_version()
 {
     Assert.Equal(
         Strings.UnableToDetermineStoreVersion,
         Assert.Throws <ArgumentException>(() => SqlVersionUtils.GetSqlVersion("2014")).Message);
 }
コード例 #11
0
 public void GetSqlVersion_returns_Sql8_for_server_version_string_greater_equal_to_8()
 {
     Assert.Equal(SqlVersion.Sql8, SqlVersionUtils.GetSqlVersion(CreateConnectionForVersion("08.12.1234")));
 }
コード例 #12
0
 public void GetSqlVersion_returns_Sql11_for_server_version_string_greater_than_or_equal_to_11()
 {
     Assert.Equal(SqlVersion.Sql11, SqlVersionUtils.GetSqlVersion(CreateConnectionForVersion("11.12.1234")));
     Assert.Equal(SqlVersion.Sql11, SqlVersionUtils.GetSqlVersion(CreateConnectionForVersion("12.12.1234")));
 }
コード例 #13
0
 public void GetServerType_returns_Cloud_for_server_with_EngineEdtion_equal_to_five()
 {
     Assert.Equal(ServerType.Cloud, SqlVersionUtils.GetServerType(CreateConnectionForAzureQuery(5).Object));
 }
コード例 #14
0
 public SqlProviderManifest(string manifestToken)
     : base(SqlProviderManifest.GetProviderManifest())
 {
     this._version = SqlVersionUtils.GetSqlVersion(manifestToken);
     this.Initialize();
 }