Beispiel #1
0
        public void CacheMatchesNullDbNameToEmptyString()
        {
            // Set sqlDw result into cache
            string dataSource = "testDataSource";
            DatabaseEngineEdition      engineEdition;
            SqlConnectionStringBuilder testSource = new SqlConnectionStringBuilder
            {
                DataSource     = dataSource,
                InitialCatalog = string.Empty
            };

            cache.AddOrUpdateCache(testSource, DatabaseEngineEdition.SqlDataWarehouse, CachedServerInfo.CacheVariable.EngineEdition);

            // Expect the same returned result
            Assert.Equal(cache.TryGetEngineEdition(testSource, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);

            // And expect the same for the null string
            Assert.Equal(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
            {
                DataSource = dataSource
                             // Initial Catalog is null. Can't set explicitly as this throws
            }, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);

            // But expect NotEqual for a different DB
            Assert.NotEqual(cache.TryGetEngineEdition(new SqlConnectionStringBuilder
            {
                DataSource     = dataSource,
                InitialCatalog = "OtherDb"
            }, out engineEdition), DatabaseEngineEdition.SqlDataWarehouse);
        }
        public void CacheMatchesNullDbNameToEmptyString()
        {
            // Set sqlDw result into cache
            string dataSource = "testDataSource";
            bool   isSqlDwResult;
            SqlConnectionStringBuilder testSource = new SqlConnectionStringBuilder
            {
                DataSource     = dataSource,
                InitialCatalog = string.Empty
            };

            cache.AddOrUpdateCache(testSource, true, CachedServerInfo.CacheVariable.IsSqlDw);

            // Expect the same returned result
            Assert.True(cache.TryGetIsSqlDw(testSource, out isSqlDwResult));
            Assert.True(isSqlDwResult);

            // And expect the same for the null string
            Assert.True(cache.TryGetIsSqlDw(new SqlConnectionStringBuilder
            {
                DataSource = dataSource
                             // Initial Catalog is null. Can't set explicitly as this throws
            }, out isSqlDwResult));
            Assert.True(isSqlDwResult);

            // But expect false for a different DB
            Assert.False(cache.TryGetIsSqlDw(new SqlConnectionStringBuilder
            {
                DataSource     = dataSource,
                InitialCatalog = "OtherDb"
            }, out isSqlDwResult));
        }