public async Task ScriptDatabaseSchemaAndData() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile tempFile = new SelfCleaningTempFile()) { ScriptingParams requestParams = new ScriptingParams { FilePath = tempFile.FilePath, ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, }; ScriptingResult result = await testService.Script(requestParams); ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(30)); ScriptingCompleteParams completeParameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30)); Assert.True(completeParameters.Success); Assert.Equal <int>(ScriptingFixture.ObjectCountWithDatabase, planEvent.Count); Assert.True(File.Exists(tempFile.FilePath)); Assert.True(new FileInfo(tempFile.FilePath).Length > 0); AssertSchemaInFile(tempFile.FilePath, assert: true); AssertTableDataInFile(tempFile.FilePath, assert: true); } }
public async Task ScriptTable() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { ScriptingParams requestParams = new ScriptingParams { ScriptDestination = "ToEditor", ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaOnly", }, ScriptingObjects = new List <ScriptingObject> { new ScriptingObject { Type = "Table", Schema = "dbo", Name = "Customers", }, } }; ScriptingResult result = await testService.Script(requestParams); ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(1)); ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30)); Assert.True(parameters.Success); Assert.Equal <int>(1, planEvent.Count); } }
public async Task ScriptTableDoesNotExist() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile tempFile = new SelfCleaningTempFile()) { ScriptingParams requestParams = new ScriptingParams { FilePath = tempFile.FilePath, ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaOnly", }, ScriptingObjects = new List <ScriptingObject> { new ScriptingObject { Type = "Table", Schema = "dbo", Name = "TableDoesNotExist", }, } }; ScriptingResult result = await testService.Script(requestParams); ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(15)); Assert.True(parameters.HasError); Assert.Equal("An error occurred while scripting the objects.", parameters.ErrorMessage); Assert.Contains("The Table '[dbo].[TableDoesNotExist]' does not exist on the server.", parameters.ErrorDetails); } }
public async Task ScriptSelectTable() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile tempFile = new SelfCleaningTempFile()) { await testService.Connect(tempFile.FilePath, testService.TestConnectionService.GetConnectionParameters(serverType: TestServerType.OnPrem)); ScriptingParams requestParams = new ScriptingParams { ScriptDestination = "ToEditor", OwnerUri = tempFile.FilePath, ScriptOptions = new ScriptOptions { ScriptCreateDrop = "ScriptSelect" }, ScriptingObjects = new List <ScriptingObject> { new ScriptingObject { Type = "Table", Schema = "dbo", Name = "Customers", } } }; ScriptingResult result = await testService.Script(requestParams); Assert.True(result.Script.Contains("SELECT")); } }
public async Task ScriptDatabaseSchemaAndData() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { ScriptingParams requestParams = new ScriptingParams { ScriptDestination = "ToEditor", ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, }; ScriptingResult result = await testService.Script(requestParams); ScriptingCompleteParams completeParameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30)); Assert.True(completeParameters.Success); } }
public async Task ScriptSchemaInvalidFilePath() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { ScriptingParams requestParams = new ScriptingParams { FilePath = "This path doesn't event exist", ConnectionString = "Server=Temp;Database=Temp;User Id=Temp;Password=Temp", ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, }; ScriptingResult result = await testService.Script(requestParams); ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10)); Assert.True(parameters.HasError); Assert.Equal("Invalid directory specified by the ScriptingParams.FilePath property.", parameters.ErrorMessage); } }
public async Task ScriptSchemaInvalidConnectionString() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { ScriptingParams requestParams = new ScriptingParams { ScriptDestination = "ToEditor", ConnectionString = "I'm an invalid connection string", ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, }; ScriptingResult result = await testService.Script(requestParams); ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10)); Assert.True(parameters.HasError); Assert.Equal("Error parsing ScriptingParams.ConnectionString property.", parameters.ErrorMessage); } }
public async void ScriptSchemaCancel() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) { ScriptingParams requestParams = new ScriptingParams { ScriptDestination = "ToEditor", ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", } }; var result = Task.Run(() => testService.Script(requestParams)); ScriptingProgressNotificationParams progressParams = await testService.Driver.WaitForEvent(ScriptingProgressNotificationEvent.Type, TimeSpan.FromSeconds(10)); Task.Run(() => testService.CancelScript(progressParams.OperationId)); ScriptingCompleteParams cancelEvent = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10)); Assert.True(cancelEvent.Canceled); } }
public async Task ScriptSchemaCancel() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile tempFile = new SelfCleaningTempFile()) { ScriptingParams requestParams = new ScriptingParams { FilePath = tempFile.FilePath, ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, }; ScriptingResult result = await testService.Script(requestParams); ScriptingCancelResult cancelResult = await testService.CancelScript(result.OperationId); ScriptingCompleteParams cancelEvent = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(10)); Assert.True(cancelEvent.Canceled); } }
public async Task ScriptTableAndData() { using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile tempFile = new SelfCleaningTempFile()) { ScriptingParams requestParams = new ScriptingParams { FilePath = tempFile.FilePath, ConnectionString = this.Northwind.ConnectionString, ScriptOptions = new ScriptOptions { TypeOfDataToScript = "SchemaAndData", }, ScriptingObjects = new List <ScriptingObject> { new ScriptingObject { Type = "Table", Schema = "dbo", Name = "Customers", }, } }; ScriptingResult result = await testService.Script(requestParams); ScriptingPlanNotificationParams planEvent = await testService.Driver.WaitForEvent(ScriptingPlanNotificationEvent.Type, TimeSpan.FromSeconds(30)); ScriptingCompleteParams parameters = await testService.Driver.WaitForEvent(ScriptingCompleteEvent.Type, TimeSpan.FromSeconds(30)); Assert.True(parameters.Success); Assert.Equal <int>(1, planEvent.Count); Assert.True(File.Exists(tempFile.FilePath)); Assert.True(new FileInfo(tempFile.FilePath).Length > 0); } }