public void Equals_Given_SameOutputs_DifferentIndexes_ActivityTools_AreNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var outputs  = new List <Common.Interfaces.DB.IServiceOutputMapping>
            {
                new ServiceOutputMapping("d", "e", "f"),
                new ServiceOutputMapping("a", "b", "c")
            };
            var outputs2 = new List <Common.Interfaces.DB.IServiceOutputMapping>
            {
                new ServiceOutputMapping("a", "b", "c"),
                new ServiceOutputMapping("d", "e", "f")
            };
            var activity = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Outputs = outputs
            };
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Outputs = outputs2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
Esempio n. 2
0
        public void PostgreSql_TestActionSetSourceAndTestClickOkHasQueryStringAndHeaders()
        {
            //------------Setup for test--------------------------
            var mod = new PostgreSqlModel();
            var act = new DsfPostgreSqlActivity();

            //------------Execute Test---------------------------
            var model = new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker());

            model.ManageServiceInputViewModel = new InputViewForTest(model, mod);
            model.SourceRegion.SelectedSource = model.SourceRegion.Sources.First();
            model.ActionRegion.SelectedAction = model.ActionRegion.Actions.First();
            model.InputArea.Inputs.Add(new ServiceInput("[[a]]", "asa"));
#pragma warning disable 4014
            model.TestInputCommand.Execute();
#pragma warning restore 4014

            model.ManageServiceInputViewModel.TestCommand.Execute(null);
            model.ManageServiceInputViewModel.IsEnabled          = true;
            model.ManageServiceInputViewModel.OutputArea.Outputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c")
            };
            model.ManageServiceInputViewModel.OkCommand.Execute(null);
#pragma warning restore 4014

            //------------Assert Results-------------------------
            Assert.IsFalse(model.SourceRegion.IsEnabled);
            Assert.IsFalse(model.OutputsRegion.IsEnabled);
            Assert.IsFalse(model.InputArea.IsEnabled);
            Assert.IsFalse(model.ErrorRegion.IsEnabled);
            Assert.IsTrue(model.ManageServiceInputViewModel.InputArea.Inputs.Count == 2);
            Assert.IsTrue(model.ManageServiceInputViewModel.InputArea.Inputs.First().Name == "[[fname]]");
            Assert.IsTrue(model.ManageServiceInputViewModel.InputArea.Inputs.Last().Name == "[[a]]");
        }
Esempio n. 3
0
        public void PostgreSql_TestActionSetSourceAndTestClickOkHasMappingsErrorFromServer()
        {
            //------------Setup for test--------------------------
            var mod = new PostgreSqlModel();

            mod.HasRecError = true;
            var act = new DsfPostgreSqlActivity();

            //------------Execute Test---------------------------
            var model = new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker());

            model.ManageServiceInputViewModel = new InputViewForTest(model, mod);
            model.SourceRegion.SelectedSource = model.SourceRegion.Sources.First();
#pragma warning disable 4014
            model.TestInputCommand.Execute();
            model.ManageServiceInputViewModel.TestCommand.Execute(null);
            model.ManageServiceInputViewModel.IsEnabled          = true;
            model.ManageServiceInputViewModel.OutputArea.Outputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c"), new ServiceOutputMapping("a", "b", "c")
            };
            model.ManageServiceInputViewModel.OkCommand.Execute(null);
#pragma warning restore 4014

            //------------Assert Results-------------------------
            Assert.IsTrue(model.ErrorRegion.IsEnabled);
        }
Esempio n. 4
0
        public void DataGridActivityFindMissingStrategy_GetActivityFields_PostgreSQL_ShouldReturnResults()
        {
            //------------Setup for test--------------------------
            Dev2FindMissingStrategyFactory fac      = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy           strategy = fac.CreateFindMissingStrategy(enFindMissingType.DataGridActivity);
            var activity = new DsfPostgreSqlActivity
            {
                Inputs = new List <IServiceInput> {
                    new ServiceInput("Input1", "[[InputValue1]]"), new ServiceInput("Input2", "[[InputValue2]]"), new ServiceInput("Input3", "[[InputValue3]]")
                },
                Outputs = new List <IServiceOutputMapping> {
                    new ServiceOutputMapping("Output1", "OutputValue1", "rec"), new ServiceOutputMapping("Output2", "OutputValue2", "rec")
                },
                OnErrorVariable = "[[err]]",
                OnErrorWorkflow = "[[errSvc]]"
            };
            //------------Execute Test---------------------------
            var fields = strategy.GetActivityFields(activity);

            //------------Assert Results-------------------------
            Assert.AreEqual(7, fields.Count);
            Assert.IsTrue(fields.Contains("[[InputValue1]]"));
            Assert.IsTrue(fields.Contains("[[InputValue2]]"));
            Assert.IsTrue(fields.Contains("[[InputValue3]]"));
            Assert.IsTrue(fields.Contains("[[rec().OutputValue1]]"));
            Assert.IsTrue(fields.Contains("[[rec().OutputValue2]]"));
            Assert.IsTrue(fields.Contains("[[err]]"));
            Assert.IsTrue(fields.Contains("[[errSvc]]"));
        }
        public void Equals_Given_SameInputsDifferentIndexes_ActivityTools_AreNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var inputs   = new List <Common.Interfaces.DB.IServiceInput>
            {
                new ServiceInput("Input2", "[[InputValue2]]"),
                new ServiceInput("Input1", "[[InputValue1]]")
            };
            var inputs2 = new List <Common.Interfaces.DB.IServiceInput>
            {
                new ServiceInput("Input1", "[[InputValue1]]"),
                new ServiceInput("Input2", "[[InputValue2]]")
            };
            var activity = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Inputs = inputs
            };
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Inputs = inputs2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
Esempio n. 6
0
        public PostgreSqlDatabaseDesignerViewModel GetViewModel()
        {
            var mod = new PostgreSqlModel();
            var act = new DsfPostgreSqlActivity();

            //------------Execute Test---------------------------
            return(new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker()));
        }
        public void UniqueIDDifferent_EmptyPostgreDatabase_Object_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId        = Guid.NewGuid().ToString();
            var activity1       = new DsfPostgreSqlActivity();
            var postgreDatabase = new DsfPostgreSqlActivity();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(postgreDatabase);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
Esempio n. 8
0
        public void SQLServer_VerifyCommandTimeout()
        {
            //------------Setup for test--------------------------
            var mod = new PostgreSqlModel();
            var act = new DsfPostgreSqlActivity();

            //------------Execute Test---------------------------
            using (var vm = new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker(), new ViewPropertyBuilder()))
            {
                vm.InputArea.CommandTimeout = 321;
                //------------Assert Results-------------------------
                var dbService = vm.ToModel();
                Assert.AreEqual(321, dbService.CommandTimeout);
            }
        }
Esempio n. 9
0
        public void PostgreSql_Refresh_ShouldLoadRefreshActions()
        {
            //------------Setup for test--------------------------
            var id        = Guid.NewGuid();
            var mod       = new PostgreSqlModel();
            var act       = new DsfPostgreSqlActivity();
            var sqlServer = new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker());

            sqlServer.ManageServiceInputViewModel = new InputViewForTest(sqlServer, mod);
            sqlServer.SourceRegion.SelectedSource = sqlServer.SourceRegion.Sources.First();
            //------------Execute Test---------------------------
            sqlServer.ActionRegion.RefreshActionsCommand.Execute(null);

            //------------Assert Results-------------------------
            Assert.IsTrue(sqlServer.SourceRegion.IsEnabled);
            Assert.AreEqual(1, sqlServer.ActionRegion.Actions.Count);
        }
Esempio n. 10
0
        public void PostgreSql_TestActionSetSource()
        {
            //------------Setup for test--------------------------
            var mod = new PostgreSqlModel();
            var act = new DsfPostgreSqlActivity();

            //------------Execute Test---------------------------

            var model = new PostgreSqlDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker());

            model.ManageServiceInputViewModel = new InputViewForTest(model, mod);
            model.SourceRegion.SelectedSource = model.SourceRegion.Sources.First();

            //------------Assert Results-------------------------
            Assert.IsTrue(model.SourceRegion.IsEnabled);
            Assert.IsFalse(model.OutputsRegion.IsEnabled);
            Assert.IsFalse(model.InputArea.IsEnabled);
            Assert.IsTrue(model.ErrorRegion.IsEnabled);
        }
Esempio n. 11
0
        public void GivenIDragAPostgresSqlServerDatabaseConnector()
        {
            var postgresActivity = new DsfPostgreSqlActivity();
            var modelItem        = ModelItemUtils.CreateModelItem(postgresActivity);

            var mockServiceInputViewModel = new Mock <IManageServiceInputViewModel>();
            var mockDbServiceModel        = new Mock <IDbServiceModel>();
            var mockEnvironmentRepo       = new Mock <IServerRepository>();
            var mockEnvironmentModel      = new Mock <IServer>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.IsLocalHost).Returns(true);
            mockEnvironmentModel.Setup(model => model.EnvironmentID).Returns(Guid.Empty);
            mockEnvironmentModel.Setup(model => model.IsLocalHostCheck()).Returns(false);
            mockEnvironmentRepo.Setup(repository => repository.ActiveServer).Returns(mockEnvironmentModel.Object);
            mockEnvironmentRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >())).Returns(mockEnvironmentModel.Object);

            _postgresSqlSource = new DbSourceDefinition
            {
                Name               = "DemoPostgres",
                Type               = enSourceType.PostgreSQL,
                ServerName         = "Localhost",
                UserName           = "******",
                Password           = "******",
                AuthenticationType = Runtime.ServiceModel.Data.AuthenticationType.User
            };

            var dbSources = new ObservableCollection <IDbSource> {
                _postgresSqlSource
            };

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);
            mockDbServiceModel.Setup(model => model.GetActions(_postgresSqlSource));
            mockServiceInputViewModel.SetupAllProperties();

            var postgresDesignerViewModel = new PostgreSqlDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker(), new ViewPropertyBuilder());

            _scenarioContext.Add("viewModel", postgresDesignerViewModel);
            _scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            _scenarioContext.Add("mockDbServiceModel", mockDbServiceModel);
        }
        public void UniqueIDEquals_EmptyPostgreDatabase_Object_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId        = Guid.NewGuid().ToString();
            var postgreDatabase = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId
            };
            var activity = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(postgreDatabase);
            //---------------Execute Test ----------------------
            var equals = postgreDatabase.Equals(activity);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
        public void Equals_Given_Same_DisplayName_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId  = Guid.NewGuid().ToString();
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, DisplayName = "a"
            };
            var postgreDatabase = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, DisplayName = "a"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(postgreDatabase);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
Esempio n. 14
0
        public void GivenIHaveWorkflowWithPostgresDatabaseConnector(string workflowName, string activityName)
        {
            var environmentModel = _scenarioContext.Get <IServer>("server");

            environmentModel.Connect();
            CreateNewResourceModel(workflowName, environmentModel);
            CreateDBServiceModel(environmentModel);

            var dbServiceModel = _scenarioContext.Get <ManageDbServiceModel>("dbServiceModel");
            var posgreActivity = new DsfPostgreSqlActivity {
                DisplayName = activityName
            };
            var modelItem = ModelItemUtils.CreateModelItem(posgreActivity);
            var posgreDesignerViewModel = new PostgreSqlDatabaseDesignerViewModel(modelItem, dbServiceModel, new SynchronousAsyncWorker(), new ViewPropertyBuilder());
            var serviceInputViewModel   = new ManageDatabaseServiceInputViewModel(posgreDesignerViewModel, posgreDesignerViewModel.Model);

            _commonSteps.AddActivityToActivityList(workflowName, activityName, posgreActivity);
            DebugWriterSubscribe(environmentModel);
            _scenarioContext.Add("viewModel", posgreDesignerViewModel);
            _scenarioContext.Add("parentName", workflowName);
        }
        public void Equals_Given_Different_ProcedureName_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId  = Guid.NewGuid().ToString();
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, ProcedureName = "A"
            };
            var postgreDatabase = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, ProcedureName = "ass"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(postgreDatabase);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
        public void Equals_Given_Same_SourceId_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId  = Guid.NewGuid().ToString();
            var sourceId  = Guid.NewGuid();;
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, SourceId = sourceId
            };
            var activity = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, SourceId = sourceId
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(activity);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
        public void Equals_Given_SameOutputs_ActivityTools_AreEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var outputs  = new List <Common.Interfaces.DB.IServiceOutputMapping>();
            var activity = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Outputs = outputs
            };
            var activity1 = new DsfPostgreSqlActivity()
            {
                UniqueID = uniqueId, Outputs = outputs
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
Esempio n. 18
0
        public static DsfPostgreSqlActivity GetDsfPostgreSqlActivity(DsfDatabaseActivity dbActivity, DbService service, DbSource source)
        {
            DsfPostgreSqlActivity dsfSqlServerDatabaseActivity = null;

            if (dbActivity != null)
            {
                dsfSqlServerDatabaseActivity = new DsfPostgreSqlActivity
                {
                    ResourceID                   = dbActivity.ResourceID,
                    DisplayName                  = dbActivity.DisplayName,
                    ProcedureName                = service.Method.ExecuteAction,
                    SourceId                     = source.ResourceID,
                    Inputs                       = TranslateInputMappingToInputs(dbActivity.InputMapping),
                    Outputs                      = TranslateOutputMappingToOutputs(dbActivity.OutputMapping),
                    ToolboxFriendlyName          = dbActivity.ToolboxFriendlyName,
                    IconPath                     = dbActivity.IconPath,
                    ServiceName                  = dbActivity.ServiceName,
                    DataTags                     = dbActivity.DataTags,
                    ResultValidationRequiredTags = dbActivity.ResultValidationRequiredTags,
                    ResultValidationExpression   = dbActivity.ResultValidationExpression,
                    FriendlySourceName           = dbActivity.FriendlySourceName,
                    EnvironmentID                = dbActivity.EnvironmentID,
                    Type                     = dbActivity.Type,
                    ActionName               = dbActivity.ActionName,
                    RunWorkflowAsync         = dbActivity.RunWorkflowAsync,
                    Category                 = dbActivity.Category,
                    ServiceUri               = dbActivity.ServiceUri,
                    ServiceServer            = dbActivity.ServiceServer,
                    UniqueID                 = dbActivity.UniqueID,
                    ParentServiceName        = dbActivity.ParentServiceName,
                    ParentServiceID          = dbActivity.ParentServiceID,
                    ParentWorkflowInstanceId = dbActivity.ParentWorkflowInstanceId,
                    ParentInstanceID         = dbActivity.ParentInstanceID,
                };
            }
            return(dsfSqlServerDatabaseActivity);
        }
Esempio n. 19
0
        public void GivenIOpenWorkflowWithPostgreSqlConnector()
        {
            var sourceId = Guid.NewGuid();
            var inputs   = new List <IServiceInput> {
                new ServiceInput("Prefix", "[[Prefix]]")
            };
            var outputs = new List <IServiceOutputMapping>
            {
                new ServiceOutputMapping("name", "name", "getemployees"),
            };

            var postgresActivity = new DsfPostgreSqlActivity();

            var modelItem = ModelItemUtils.CreateModelItem(postgresActivity);
            var mockServiceInputViewModel = new Mock <IManageServiceInputViewModel>();
            var mockDbServiceModel        = new Mock <IDbServiceModel>();
            var mockEnvironmentRepo       = new Mock <IServerRepository>();
            var mockEnvironmentModel      = new Mock <IServer>();

            mockEnvironmentModel.Setup(model => model.IsConnected).Returns(true);
            mockEnvironmentModel.Setup(model => model.IsLocalHost).Returns(true);
            mockEnvironmentModel.Setup(model => model.EnvironmentID).Returns(Guid.Empty);
            mockEnvironmentModel.Setup(model => model.IsLocalHostCheck()).Returns(false);
            mockEnvironmentRepo.Setup(repository => repository.ActiveServer).Returns(mockEnvironmentModel.Object);
            mockEnvironmentRepo.Setup(repository => repository.FindSingle(It.IsAny <Expression <Func <IServer, bool> > >())).Returns(mockEnvironmentModel.Object);

            _postgresSqlSource = new DbSourceDefinition
            {
                Name               = "postgressql",
                Type               = enSourceType.PostgreSQL,
                ServerName         = "Localhost",
                UserName           = "******",
                Password           = "******",
                AuthenticationType = Runtime.ServiceModel.Data.AuthenticationType.User
            };

            _testingDbSource = new DbSourceDefinition
            {
                Name = "testingDBSrc",
                Type = enSourceType.PostgreSQL,
                Id   = sourceId
            };

            _selectedAction = new DbAction
            {
                Name   = "getemployees",
                Inputs = new List <IServiceInput> {
                    new ServiceInput("fname", "")
                }
            };

            _getEmployees = new DbAction {
                Name = "getemployees"
            };
            _getEmployees.Inputs = inputs;
            var dbSources = new ObservableCollection <IDbSource> {
                _testingDbSource, _postgresSqlSource
            };

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);
            mockDbServiceModel.Setup(model => model.GetActions(It.IsAny <IDbSource>())).Returns(new List <IDbAction> {
                _getEmployees, _selectedAction
            });
            mockServiceInputViewModel.SetupAllProperties();
            var postgresDesignerViewModel = new PostgreSqlDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker(), new ViewPropertyBuilder());

            _scenarioContext.Add("viewModel", postgresDesignerViewModel);
            _scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            _scenarioContext.Add("mockDbServiceModel", mockDbServiceModel);
        }