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);
                }
        }
Beispiel #2
0
        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);
                }
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        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);
                }
        }
Beispiel #10
0
 private void SendCompletionNotificationEvent(ScriptingCompleteParams parameters)
 {
     this.SetCommomEventProperties(parameters);
     this.CompleteNotification?.Invoke(this, parameters);
 }
Beispiel #11
0
 protected override void SendCompletionNotificationEvent(ScriptingCompleteParams parameters)
 {
     base.SendCompletionNotificationEvent(parameters);
 }
 protected virtual void SendCompletionNotificationEvent(ScriptingCompleteParams parameters)
 {
     this.CompleteNotification?.Invoke(this, parameters);
 }
 protected override void SendCompletionNotificationEvent(ScriptingCompleteParams parameters)
 {
     this.SetCommonEventProperties(parameters);
     base.SendCompletionNotificationEvent(parameters);
 }