public static void ClassInit(TestContext context)
        {
            var aggr = new Mock <IEventAggregator>();

            DataListSingleton.SetDataList(new DataListViewModel(aggr.Object));
            _containerOps = TestLauncher.StartLocalMSSQLContainer(context.ResultsDirectory);
        }
        static DbSource CreateDev2TestingDbSource()
        {
            _containerOps = TestLauncher.StartLocalMSSQLContainer(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestResults"));
            var dbSource = new DbSource
            {
                ResourceID         = Guid.NewGuid(),
                ResourceName       = "Dev2TestingDB",
                DatabaseName       = "Dev2TestingDB",
                Server             = "TEST-MSSQL",
                AuthenticationType = AuthenticationType.User,
                ServerType         = enSourceType.SqlDatabase,
                ReloadActions      = true,
                UserID             = "testUser",
                Password           = "******",
                ConnectionTimeout  = 30
            };

            return(dbSource);
        }
        public void GivenISelectAsSqlServerSourceFor(string sourceName, string activityName)
        {
            if (sourceName == "NewSqlServerSource")
            {
                _containerOps = TestLauncher.StartLocalMSSQLContainer(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestResults"));
            }
            var proxyLayer = _scenarioContext.Get <StudioServerProxy>("proxyLayer");
            var vm         = GetViewModel();

            Assert.IsNotNull(vm.SourceRegion);
            var dbSources = proxyLayer.QueryManagerProxy.FetchDbSources().ToList();

            Assert.IsNotNull(dbSources, "dbSources is null");
            var dbSource = dbSources.Single(source => source.Name == sourceName);

            Assert.IsNotNull(dbSource, "Source is null");
            vm.SourceRegion.SelectedSource = dbSource;
            SetDbSource(activityName, dbSource);
            Assert.IsNotNull(vm.SourceRegion.SelectedSource);
        }
Ejemplo n.º 4
0
        public void GetDatabaseTables_Execute_ValidDatabaseSource()
        {
            var parser = new Mock <IActivityParser>();

            parser.Setup(a => a.Parse(It.IsAny <DynamicActivity>())).Returns(new Mock <IDev2Activity>().Object);
            CustomContainer.Register(parser.Object);
            //------------Setup for test--------------------------
            GetDatabaseColumnsForTableTests._containerOps = TestLauncher.StartLocalMSSQLContainer(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestResults"));
            var dbSource = CreateDev2TestingDbSource();

            ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource, "");
            var someJsonData  = JsonConvert.SerializeObject(dbSource);
            var esb           = new GetDatabaseTables();
            var mockWorkspace = new Mock <IWorkspace>();

            mockWorkspace.Setup(workspace => workspace.ID).Returns(Guid.Empty);
            //------------Execute Test---------------------------
            var actual = esb.Execute(new Dictionary <string, StringBuilder> {
                { "Database", new StringBuilder(someJsonData) }
            }, mockWorkspace.Object);
            //------------Assert Results-------------------------
            var value = actual.ToString();

            Assert.IsFalse(string.IsNullOrEmpty(value));
            var result = JsonConvert.DeserializeObject <DbTableList>(value);

            Assert.IsTrue(result.Items.Count > 2);
            var duplicateTables = result.Items.FindAll(table => table.TableName.Contains("[City]"));

            Assert.AreEqual(2, duplicateTables.Count);
            var dboCityTable      = duplicateTables.Find(table => table.Schema == "dbo");
            var warewolfCityTable = duplicateTables.Find(table => table.Schema == "Warewolf");

            Assert.IsNotNull(dboCityTable);
            Assert.AreEqual("dbo", dboCityTable.Schema);
            Assert.IsNotNull(warewolfCityTable);
            Assert.AreEqual("Warewolf", warewolfCityTable.Schema);
        }
Ejemplo n.º 5
0
 public static void MyClassInitialize(TestContext testContext)
 {
     _containerOps = TestLauncher.StartLocalMSSQLContainer(testContext.ResultsDirectory);
     Thread.Sleep(10000);
 }
Ejemplo n.º 6
0
        public void SetupScenerio()
        {
            _containerOps = TestLauncher.StartLocalMSSQLContainer(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestResults"));
            var dbSource = SqlServerTestUtils.CreateDev2TestingDbSource();

            ResourceCatalog.Instance.SaveResource(Guid.Empty, dbSource, "");
            scenarioContext.Add("dbSource", dbSource);

            var sqlBulkInsert = new DsfSqlBulkInsertActivity();

            sqlBulkInsert.Database  = dbSource;
            sqlBulkInsert.TableName = "SqlBulkInsertSpecFlowTestTable_for_" + scenarioContext.ScenarioInfo.Title.Replace(' ', '_');
            if (scenarioContext.ScenarioInfo.Title.Replace(' ', '_') == "Import_data_into_Table_Batch_size_is_1")
            {
                var tableNameUniqueNameGuid = CommonSteps.GetGuid();
                CreateIsolatedSQLTable(tableNameUniqueNameGuid);
                scenarioContext.Add("tableNameUniqueNameGuid", tableNameUniqueNameGuid);
                sqlBulkInsert.TableName += "_" + tableNameUniqueNameGuid;
            }
            var dataColumnMappings = new List <DataColumnMapping>
            {
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col1]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col1",
                        DataType   = typeof(Int32),
                        MaxLength  = 100
                    },
                },
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col2]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col2",
                        DataType   = typeof(String),
                        MaxLength  = 100
                    }
                },
                new DataColumnMapping
                {
                    InputColumn  = "[[rs(*).Col3]]",
                    OutputColumn = new DbColumn
                    {
                        ColumnName = "Col3",
                        DataType   = typeof(Guid),
                        MaxLength  = 100
                    }
                }
            };

            sqlBulkInsert.InputMappings = dataColumnMappings;
            TestStartNode = new FlowStep
            {
                Action = sqlBulkInsert
            };

            scenarioContext.Add("activity", sqlBulkInsert);
        }