Пример #1
0
        public void Test_Erase_Option_No_Explicit_Options()
        {
            //arrange
            var traceService       = new Mock <ITraceService>();
            var environmentService = new Mock <IEnvironmentService>();

            environmentService.Setup(s => s.GetCurrentDirectory()).Returns(@"c:\temp\yuniql");
            environmentService.Setup(s => s.GetEnvironmentVariable("YUNIQL_CONNECTION_STRING")).Returns("sqlserver-connection-string");
            var localVersionService = new Mock <ILocalVersionService>();

            var migrationService        = new Mock <IMigrationService>();
            var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>();

            migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object);

            //act
            var option = new EraseOption {
                Tokens = new List <string> {
                    "Token1=TokenValue1", "Token2=TokenValue2", "Token3=TokenValue3"
                }
            };
            var sut = new CommandLineService(migrationServiceFactory.Object, localVersionService.Object, environmentService.Object, traceService.Object);

            sut.RunEraseOption(option);

            //assert
            migrationService.Verify(s => s.Initialize("sqlserver-connection-string", DEFAULT_CONSTANTS.COMMAND_TIMEOUT_SECS));
            migrationService.Verify(s => s.Erase(@"c:\temp\yuniql",
                                                 It.Is <List <KeyValuePair <string, string> > >(x =>
                                                                                                x[0].Key == "Token1" && x[0].Value == "TokenValue1" &&
                                                                                                x[1].Key == "Token2" && x[1].Value == "TokenValue2" &&
                                                                                                x[2].Key == "Token3" && x[2].Value == "TokenValue3"
                                                                                                ), DEFAULT_CONSTANTS.COMMAND_TIMEOUT_SECS, null));
        }
Пример #2
0
        public void Test_Erase_Option_No_Explicit_Options()
        {
            //arrange
            var traceService       = new Mock <ITraceService>();
            var environmentService = new Mock <IEnvironmentService>();

            environmentService.Setup(s => s.GetCurrentDirectory()).Returns(@"c:\temp\yuniql");
            environmentService.Setup(s => s.GetEnvironmentVariable("YUNIQL_CONNECTION_STRING")).Returns("sqlserver-connection-string");
            var workspaceService = new Mock <IWorkspaceService>();

            var configuration = Configuration.Instance;

            configuration.Workspace        = @"C:\temp\yuniql";
            configuration.Platform         = SUPPORTED_DATABASES.SQLSERVER;
            configuration.ConnectionString = "sqlserver-connection-string";

            var configurationService = new Mock <IConfigurationService>();

            configurationService.Setup(s => s.GetValueOrDefault(null, ENVIRONMENT_VARIABLE.YUNIQL_PLATFORM, SUPPORTED_DATABASES.SQLSERVER)).Returns(SUPPORTED_DATABASES.SQLSERVER);
            configurationService.Setup(s => s.Initialize());

            var migrationService        = new Mock <IMigrationService>();
            var migrationServiceFactory = new Mock <CLI.IMigrationServiceFactory>();

            migrationServiceFactory.Setup(s => s.Create("sqlserver")).Returns(migrationService.Object);

            var dataService        = new Mock <IDataService>();
            var dataServiceFactory = new Mock <CLI.IDataServiceFactory>();

            dataServiceFactory.Setup(s => s.Create("sqlserver")).Returns(dataService.Object);

            var manifest        = new Mock <ManifestData>();
            var manifestFactory = new Mock <IManifestFactory>();

            manifestFactory.Setup(s => s.Create("sqlserver")).Returns(manifest.Object);

            //act
            var option = new EraseOption {
            };
            var sut    = new CommandLineService(migrationServiceFactory.Object, dataServiceFactory.Object, manifestFactory.Object, workspaceService.Object, environmentService.Object, traceService.Object, configurationService.Object);

            sut.RunEraseOption(option);

            //assert
            migrationService.Verify(s => s.Erase());
        }