Пример #1
0
        public async Task ShouldProduceWarningWhenRunningAgainstLowerThanRecommendedAzureSqlTier()
        {
            var mockCloudOdsDatabaseNameProvider = new Mock <ICloudOdsDatabaseNameProvider>();

            mockCloudOdsDatabaseNameProvider.Setup(x => x.GetDatabaseName(It.IsAny <CloudOdsDatabases>()))
            .Returns(It.IsAny <string>());

            var azureCloudOdsWebsitePerformanceLevelQuery = new Mock <IGetAzureCloudOdsWebsitePerformanceLevelQuery>();

            azureCloudOdsWebsitePerformanceLevelQuery.Setup(x => x.Execute(It.IsAny <ICloudOdsOperationContext>()))
            .ReturnsAsync(AzureWebsitePerformanceLevel.S3);

            var mockRawSqlConnection = new Mock <IRawSqlConnectionService>();

            mockRawSqlConnection.Setup(x => x.GetDatabaseConnectionFromConfigFile(It.IsAny <string>())).Returns((SqlConnection)null);

            var azureDbManagementService = new Mock <AzureDatabaseManagementService>(mockRawSqlConnection.Object);

            azureDbManagementService.Setup(x => x.GetDatabasePerformanceLevel(It.IsAny <SqlConnection>(), It.IsAny <string>()))
            .Returns(AzureSqlDatabasePerformanceLevel.S1);

            var cloudOdsInstance = GetAzureCloudOdsInstance();

            var sut    = new GetAzureProductionApiProvisioningWarningsQuery(azureDbManagementService.Object, azureCloudOdsWebsitePerformanceLevelQuery.Object, mockRawSqlConnection.Object, mockCloudOdsDatabaseNameProvider.Object);
            var result = await sut.Execute(cloudOdsInstance);

            result.Warnings.Count().ShouldBe(1);
            result.Warnings.First().ShouldBe("Azure Sql performance tier 'P1' or above is recommended");
        }
Пример #2
0
        public async Task ShouldNotProduceWarningWhenRunningAgainstNonAzureSql()
        {
            var cloudOdsInstance = GetAzureCloudOdsInstance();

            var mockCloudOdsDatabaseNameProvider = new Mock <ICloudOdsDatabaseNameProvider>();

            mockCloudOdsDatabaseNameProvider.Setup(x => x.GetDatabaseName(It.IsAny <CloudOdsDatabases>()))
            .Returns(It.IsAny <string>());

            var azureCloudOdsWebsitePerformanceLevelQuery = new Mock <IGetAzureCloudOdsWebsitePerformanceLevelQuery>();

            azureCloudOdsWebsitePerformanceLevelQuery.Setup(x => x.Execute(It.IsAny <ICloudOdsOperationContext>()))
            .ReturnsAsync(AzureWebsitePerformanceLevel.S3);

            var mockRawSqlConnection = new Mock <IRawSqlConnectionService>();

            mockRawSqlConnection.Setup(x => x.GetDatabaseConnectionFromConfigFile(It.IsAny <string>())).Returns((SqlConnection)null);

            var azureDbManagementService = new Mock <AzureDatabaseManagementService>(mockRawSqlConnection.Object);

            azureDbManagementService.Setup(x => x.GetDatabasePerformanceLevel(It.IsAny <SqlConnection>(), It.IsAny <string>()))
            .Returns(new AzureSqlDatabasePerformanceLevel(null, null));

            var sut = new GetAzureProductionApiProvisioningWarningsQuery(
                azureDbManagementService.Object,
                azureCloudOdsWebsitePerformanceLevelQuery.Object,
                mockRawSqlConnection.Object,
                mockCloudOdsDatabaseNameProvider.Object);
            var result = await sut.Execute(cloudOdsInstance);

            result.Warnings.ShouldBeEmpty();
        }