Exemple #1
0
        public void DbSourceDefinition_GetHashCode_Not_Equal_To_Zero()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDatabaseName       = "warewolfDb";
            const string             expectedPassword           = "******";
            const string             expectedServer             = "localhost";
            const int          expectedConnectionTimeout        = 30;
            const enSourceType expectedServerType = enSourceType.SqlDatabase;
            const string       expectedUserId     = "userId";

            var mockDb = new Mock <IDb>();

            mockDb.Setup(db => db.Server).Returns(expectedServer);
            mockDb.Setup(db => db.ServerType).Returns(expectedServerType);
            mockDb.Setup(db => db.UserID).Returns(expectedUserId);
            mockDb.Setup(db => db.Password).Returns(expectedPassword);
            mockDb.Setup(db => db.AuthenticationType).Returns(expectedAuthenticationType);
            mockDb.Setup(db => db.ConnectionTimeout).Returns(expectedConnectionTimeout);
            mockDb.Setup(db => db.DatabaseName).Returns(expectedDatabaseName);

            var dbSourceDefinition = new DbSourceDefinition(mockDb.Object);

            var hashCode = dbSourceDefinition.GetHashCode();

            Assert.AreNotEqual(0, hashCode);
        }
Exemple #2
0
        public void DbSourceDefinition_Equals_Object_GetType_Expected_False()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDatabaseName       = "warewolfDb";
            var                expectedResourceID        = Guid.NewGuid();
            const string       expectedPassword          = "******";
            const string       expectedServer            = "localhost";
            const int          expectedConnectionTimeout = 30;
            const enSourceType expectedServerType        = enSourceType.SqlDatabase;
            const string       expectedUserId            = "userId";

            var mockDb = new Mock <IDb>();

            mockDb.Setup(db => db.Server).Returns(expectedServer);
            mockDb.Setup(db => db.ServerType).Returns(expectedServerType);
            mockDb.Setup(db => db.UserID).Returns(expectedUserId);
            mockDb.Setup(db => db.Password).Returns(expectedPassword);
            mockDb.Setup(db => db.AuthenticationType).Returns(expectedAuthenticationType);
            mockDb.Setup(db => db.ResourceID).Returns(expectedResourceID);
            mockDb.Setup(db => db.DatabaseName).Returns(expectedDatabaseName);
            mockDb.Setup(db => db.ConnectionTimeout).Returns(expectedConnectionTimeout);

            var dbSourceDefinition = new DbSourceDefinition(mockDb.Object);

            var dbSource = new object();

            var isEqual = dbSourceDefinition.Equals(dbSource);

            Assert.IsFalse(isEqual);
        }
        public void DatabaseActionRegion_ChangeActionSomethingChanged_CloneRegion_ExpectedClone()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            var sourceRegion = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfSqlServerDatabaseActivity()), enSourceType.SqlDatabase);

            //------------Execute Test---------------------------
            var dbActionRegion = new DbActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, new SynchronousAsyncWorker());
            var cloned         = dbActionRegion.CloneRegion();

            //------------Assert Results-------------------------
            Assert.AreEqual(cloned.IsEnabled, dbActionRegion.IsEnabled);
            Assert.AreEqual(((DbActionMemento)cloned).SelectedAction, dbActionRegion.SelectedAction);
        }
Exemple #4
0
        public void DatabaseSourceRegion_ChangeSourceSomethingChanged_ExpectedChange_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var evt = false;
            var s2  = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act), enSourceType.SqlDatabase);

            region.SomethingChanged += (a, b) => { evt = true; };
            region.SelectedSource    = s2;

            //------------Assert Results-------------------------
            Assert.IsTrue(evt);
        }
Exemple #5
0
        public void DatabaseSourceRegion_ConstructorWithSelectedSource_Scenerio_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc
            });

            //------------Execute Test---------------------------
            var region = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act), enSourceType.SqlDatabase);

            //------------Assert Results-------------------------
            Assert.AreEqual(dbsrc, region.SelectedSource);
            Assert.IsTrue(region.CanEditSource());
        }
Exemple #6
0
        public void DatabaseSourceRegion_ChangeSourceSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act), enSourceType.SqlDatabase);

            var regionToRestore = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act), enSourceType.SqlDatabase);

            regionToRestore.SelectedSource = s2;

            region.RestoreRegion(regionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(region.SelectedSource, s2);
        }
Exemple #7
0
        public void GivenIDragASqlServerDatabaseConnector()
        {
            var sqlServerActivity         = new DsfSqlServerDatabaseActivity();
            var modelItem                 = ModelItemUtils.CreateModelItem(sqlServerActivity);
            var mockServiceInputViewModel = new Mock <IManageDatabaseInputViewModel>();
            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);

            _greenPointSource = new DbSourceDefinition
            {
                Name = "GreenPoint",
                Type = enSourceType.SqlDatabase
            };

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

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);
            mockServiceInputViewModel.SetupAllProperties();
            var sqlServerDesignerViewModel = new SqlServerDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker());

            scenarioContext.Add("viewModel", sqlServerDesignerViewModel);
            scenarioContext.Add("mockServiceInputViewModel", mockServiceInputViewModel);
            scenarioContext.Add("mockDbServiceModel", mockDbServiceModel);
        }
Exemple #8
0
        public IDbSource FetchDbSource(Guid resourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(resourceID);
            var db   = new DbSource(xaml.ToXElement());
            var def  = new DbSourceDefinition(db);

            return(def);
        }
Exemple #9
0
        public void GivenIOpenAnExistingMysqlConnectorTool()
        {
            var mysqlActivity = new DsfMySqlDatabaseActivity();
            var modelItem     = ModelItemUtils.CreateModelItem(mysqlActivity);

            var mockDatabaseInputViewModel = new Mock <IManageDatabaseInputViewModel>();
            var mockDbServiceModel         = new Mock <IDbServiceModel>();

            var mockEnvironmentRepo  = new Mock <IServerRepository>();
            var mockEnvironmentModel = new Mock <IServer>();

            _outputMapping = new Mock <IServiceOutputMapping>();

            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);

            _sqlSource = new DbSourceDefinition
            {
                Name               = "DemoSqlsource",
                Type               = enSourceType.MySqlDatabase,
                ServerName         = "Localhost",
                UserName           = "******",
                Password           = "******",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.User
            };
            _anotherSqlSource = new DbSourceDefinition
            {
                Name               = "AnotherSqlSource",
                Type               = enSourceType.MySqlDatabase,
                ServerName         = "Localhost",
                UserName           = "******",
                Password           = "******",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.User
            };
            var dbSources = new ObservableCollection <IDbSource> {
                _sqlSource, _anotherSqlSource
            };

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);
            mockDbServiceModel.Setup(model => model.GetActions(_sqlSource));
            mockDatabaseInputViewModel.SetupAllProperties();

            mockDatabaseInputViewModel.Setup(model => model.OkSelected).Returns(true);

            var mysqlDesignerViewModel = new MySqlDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker(), new ViewPropertyBuilder());

            var selectedSource = SetupSelectedSource(mysqlDesignerViewModel);

            _scenarioContext.Add("viewModel", mysqlDesignerViewModel);
            _scenarioContext.Add("mockDatabaseInputViewModel", mockDatabaseInputViewModel);
            _scenarioContext.Add("mockDbServiceModel", mockDbServiceModel);

            SetupActions(selectedSource);
        }
        public void DatabaseActionRegion_ChangeActionSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var action = new DbAction()
            {
                Name = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            var sourceRegion = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfSqlServerDatabaseActivity()), enSourceType.SqlDatabase);

            //------------Execute Test---------------------------
            var dbActionRegion = new DbActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, new SynchronousAsyncWorker());

            var dbActionRegionToRestore = new DbActionMemento
            {
                IsEnabled      = false,
                SelectedAction = action,
                ToolRegionName = "New Tool Action Region",
                Dependants     = new List <IToolRegion> {
                    new DbActionMemento()
                },
                Errors = new List <string> {
                    "New Action Region Error"
                },
                Actions = new List <IDbAction> {
                    new DbAction()
                },
                IsActionEnabled = true,
                IsRefreshing    = false,
                LabelWidth      = 1.0
            };

            dbActionRegion.RestoreRegion(dbActionRegionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(dbActionRegion.SelectedAction, action);
            Assert.IsFalse(dbActionRegion.IsEnabled);
        }
        public void DatabaseActionRegion_ChangeActionSomethingChanged_RegionsNotRestored_Invalid()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var action = new DbAction()
            {
                Name = "bravo"
            };

            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var action1 = new DbAction()
            {
                Name = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            var sourceRegion = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfSqlServerDatabaseActivity()), enSourceType.SqlDatabase);

            //------------Execute Test---------------------------
            var dbActionRegion = new DbActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, new SynchronousAsyncWorker());

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            dbActionRegion.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            dbActionRegion.SelectedAction = action;
            dbActionRegion.SelectedAction = action1;

            //------------Assert Results-------------------------
            dep1.Verify(a => a.RestoreRegion(clone1.Object), Times.Never);
            dep2.Verify(a => a.RestoreRegion(clone2.Object), Times.Never);
        }
Exemple #12
0
        public void DbSourceDefinition_GetHashCode_Expect_Zero()
        {
            var mockDb = new Mock <IDb>();

            var dbSourceDefinition = new DbSourceDefinition(mockDb.Object);

            var hashCode = dbSourceDefinition.GetHashCode();

            Assert.AreEqual(0, hashCode);
        }
Exemple #13
0
        public void DbSourceDefinition_Equals_DbSource_Null_Expected_False()
        {
            var dbSourceDefinition = new DbSourceDefinition();

            const IDbSource dbSource = null;

            var isEqual = dbSourceDefinition.Equals(dbSource);

            Assert.IsFalse(isEqual);
        }
        public void GivenIOpenNewOracleDbWorkflow()
        {
            var oracleServerActivity = new DsfOracleDatabaseActivity();
            var modelItem            = ModelItemUtils.CreateModelItem(oracleServerActivity);

            var mockInputArea              = new Mock <IGenerateInputArea>();
            var mockOutputArea             = new Mock <IGenerateOutputArea>();
            var mockDatabaseInputViewModel = new Mock <IManageDatabaseInputViewModel>();
            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);

            _greenPointSource = new DbSourceDefinition
            {
                Name               = "GreenPoint",
                Type               = enSourceType.Oracle,
                ServerName         = "Localhost",
                UserName           = "******",
                Password           = "******",
                AuthenticationType = Runtime.ServiceModel.Data.AuthenticationType.User
            };

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

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);

            var mockAction = new Mock <Action>(MockBehavior.Default);

            mockDatabaseInputViewModel.SetupGet(model => model.InputArea).Returns(mockInputArea.Object);
            mockDatabaseInputViewModel.SetupGet(model => model.OutputArea).Returns(mockOutputArea.Object);
            mockDatabaseInputViewModel.Setup(model => model.TestAction).Returns(mockAction.Object);
            mockDatabaseInputViewModel.Setup(model => model.OkAction).Returns(mockAction.Object);

            var oracleServerDesignerViewModel = new OracleDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker(), new ViewPropertyBuilder());

            oracleServerDesignerViewModel.ManageServiceInputViewModel = mockDatabaseInputViewModel.Object;

            AddScenarioContext(oracleServerDesignerViewModel, mockDatabaseInputViewModel, mockDbServiceModel);
        }
Exemple #15
0
        public void DbSource_Equals_WithNotEqualOperator_ShouldNotBeEqual()
        {
            //---------------Set up test pack-------------------
            var firstObject = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var secondObject = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.IsTrue(firstObject != secondObject, "DbSourceDefinition object not equals operator broken.");
        }
Exemple #16
0
        public void DatabaseSourceRegion_ChangeSourceSomethingChanged_RestoreRegion_Result()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id, Name = "bob"
            };

            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid(), Name = "bob"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            //------------Execute Test---------------------------
            var region = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(act), enSourceType.SqlDatabase);

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            region.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            region.SelectedSource = s2;
            region.SelectedSource = dbsrc;

            //------------Assert Results-------------------------
            dep1.Verify(a => a.RestoreRegion(clone1.Object), Times.Never);
            dep2.Verify(a => a.RestoreRegion(clone2.Object), Times.Never);
        }
Exemple #17
0
        public void DbSourceDefinition_Validate()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedDatabaseName       = "warewolfDb";
            var                expectedResourceID        = Guid.NewGuid();
            const string       expectedSavePath          = "Path\\ResourcePath";
            const string       expectedResourceName      = "testResource";
            const string       expectedPassword          = "******";
            const string       expectedServer            = "localhost";
            const int          expectedConnectionTimeout = 30;
            const enSourceType expectedServerType        = enSourceType.SqlDatabase;
            const string       expectedUserId            = "userId";

            var mockDb = new Mock <IDb>();

            mockDb.Setup(db => db.AuthenticationType).Returns(expectedAuthenticationType);
            mockDb.Setup(db => db.DatabaseName).Returns(expectedDatabaseName);
            mockDb.Setup(db => db.ResourceID).Returns(expectedResourceID);
            mockDb.Setup(db => db.GetSavePath()).Returns(expectedSavePath);
            mockDb.Setup(db => db.ResourceName).Returns(expectedResourceName);
            mockDb.Setup(db => db.Password).Returns(expectedPassword);
            mockDb.Setup(db => db.Server).Returns(expectedServer);
            mockDb.Setup(db => db.ConnectionTimeout).Returns(expectedConnectionTimeout);
            mockDb.Setup(db => db.ServerType).Returns(expectedServerType);
            mockDb.Setup(db => db.UserID).Returns(expectedUserId);

            var dbSourceDefinition = new DbSourceDefinition(mockDb.Object)
            {
                ReloadActions = true
            };

            Assert.IsTrue(dbSourceDefinition.ReloadActions);

            Assert.AreEqual(expectedAuthenticationType, dbSourceDefinition.AuthenticationType);
            Assert.AreEqual(expectedDatabaseName, dbSourceDefinition.DbName);
            Assert.AreEqual(expectedResourceID, dbSourceDefinition.Id);
            Assert.AreEqual(expectedSavePath, dbSourceDefinition.Path);
            Assert.AreEqual(expectedResourceName, dbSourceDefinition.Name);
            Assert.AreEqual(expectedPassword, dbSourceDefinition.Password);
            Assert.AreEqual(expectedServer, dbSourceDefinition.ServerName);
            Assert.AreEqual(expectedConnectionTimeout, dbSourceDefinition.ConnectionTimeout);
            Assert.AreEqual(expectedServerType, dbSourceDefinition.Type);
            Assert.AreEqual(expectedUserId, dbSourceDefinition.UserName);
            Assert.AreEqual(expectedResourceName, dbSourceDefinition.ToString());
        }
        public void DatabaseActionRegion_ChangeActionSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id
            };
            var s2 = new DbSourceDefinition()
            {
                Id = Guid.NewGuid()
            };
            var action = new DbAction()
            {
                Name = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc, s2
            });

            DatabaseSourceRegion sourceRegion = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfSqlServerDatabaseActivity()), enSourceType.SqlDatabase);

            //------------Execute Test---------------------------
            DbActionRegion dbActionRegion = new DbActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, new SynchronousAsyncWorker());
            // ReSharper disable once UseObjectOrCollectionInitializer
            DbActionMemento dbActionRegionToRestore = new DbActionMemento();

            dbActionRegionToRestore.IsEnabled      = false;
            dbActionRegionToRestore.SelectedAction = action;

            dbActionRegion.RestoreRegion(dbActionRegionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(dbActionRegion.SelectedAction, action);
            Assert.IsFalse(dbActionRegion.IsEnabled);
        }
Exemple #19
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);
        }
Exemple #20
0
        public void GivenIOpen(string name)
        {
            var manageDatabaseSourceControl = ScenarioContext.Current.Get <ManageDatabaseSourceControl>(Utils.ViewNameKey);
            var upd   = FeatureContext.Current.Get <Mock <IManageDatabaseSourceModel> >("updateManager").Object;
            var dbsrc = new DbSourceDefinition
            {
                Name               = name,
                Id                 = Guid.NewGuid(),
                ServerName         = "RSAKLFSVRDEV",
                AuthenticationType = AuthenticationType.Windows
            };

            FeatureContext.Current["dbsrc"] = dbsrc;
            var mockEventAggregator = new Mock <IEventAggregator>();
            var viewModel           = new ManagePostgreSqlSourceViewModel(upd, mockEventAggregator.Object, dbsrc, new SynchronousAsyncWorker());

            if (manageDatabaseSourceControl.DataContext is ManagePostgreSqlSourceViewModel manageDatabaseSourceViewModel)
            {
                Utils.ResetViewModel <ManagePostgreSqlSourceViewModel, IDbSource>(viewModel, manageDatabaseSourceViewModel);
            }
        }
        public void GivenIOpen(string name)
        {
            var manageDatabaseSourceControl = ScenarioContext.Current.Get <ManageDatabaseSourceControl>(Utils.ViewNameKey);
            var mock  = FeatureContext.Current.Get <Mock <IManageDatabaseSourceModel> >("updateManager");
            var upd   = mock.Object;
            var dbsrc = new DbSourceDefinition
            {
                Name               = name,
                Id                 = Guid.NewGuid(),
                ServerName         = "TEST-MSSQL",
                AuthenticationType = AuthenticationType.Windows
            };

            mock.Setup(model => model.FetchDbSource(It.IsAny <Guid>())).Returns(dbsrc);
            FeatureContext.Current["dbsrc"] = dbsrc;
            var mockEventAggregator = new Mock <IEventAggregator>();
            var viewModel           = new ManageSqlServerSourceViewModel(upd, mockEventAggregator.Object, dbsrc, new SynchronousAsyncWorker());

            if (manageDatabaseSourceControl.DataContext is ManageSqlServerSourceViewModel manageDatabaseSourceViewModel)
            {
                Utils.ResetViewModel <ManageSqlServerSourceViewModel, IDbSource>(viewModel, manageDatabaseSourceViewModel);
            }
        }
        public void Execute_Problemtestingconnection_GivenNullBrokerResult_ReturnsError()
        {
            //------------Setup for test--------------------------
            var db = new Mock <IDbSources>();

            db.Setup(a => a.DoDatabaseValidation(It.IsAny <DbSource>())).Returns(default(DatabaseValidationResult));
            var service            = new TestDbSourceService(db.Object);
            var dbSourceDefinition = new DbSourceDefinition();

            //------------Execute Test---------------------------
            var stringBuilder = service.Execute(new Dictionary <string, StringBuilder>()
            {
                { "DbSource", dbSourceDefinition.SerializeToJsonStringBuilder() }
            }, It.IsAny <IWorkspace>());

            //------------Assert Results-------------------------
            Assert.AreEqual("TestDbSourceService", service.HandlesType());
            db.Verify(a => a.DoDatabaseValidation(It.IsAny <DbSource>()), Times.Once);
            var message = stringBuilder.DeserializeToObject <ExecuteMessage>();

            Assert.AreEqual("Problem testing connection.", message.Message.ToString());
            Assert.IsTrue(message.HasError);
        }
        public void DatabaseActionRegion_ConstructorWithSelectedAction_IsRefreshingTrue_IsActionEnabledFalse()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfSqlServerDatabaseActivity()
            {
                SourceId = id
            };
            var src   = new Mock <IDbServiceModel>();
            var dbsrc = new DbSourceDefinition()
            {
                Id = id, Name = "johnny"
            };
            var action = new DbAction()
            {
                Name = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IDbSource>()
            {
                dbsrc
            });

            var sourceRegion = new DatabaseSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfSqlServerDatabaseActivity()), enSourceType.SqlDatabase);

            sourceRegion.SelectedSource = dbsrc;

            //------------Execute Test---------------------------
            var dbActionRegion = new DbActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, new SynchronousAsyncWorker());

            dbActionRegion.SelectedAction = action;
            dbActionRegion.IsRefreshing   = true;
            //------------Assert Results-------------------------
            Assert.AreEqual(action, dbActionRegion.SelectedAction);
            Assert.IsFalse(dbActionRegion.CanRefresh());
        }
        public void GivenIOpenWolf()
        {
            var sourceId = Guid.NewGuid();
            var inputs   = new List <IServiceInput> {
                new ServiceInput("Prefix", "[[Prefix]]")
            };
            var outputs = new List <IServiceOutputMapping>
            {
                new ServiceOutputMapping("CountryID", "CountryID", "dbo_Pr_CitiesGetCountries"),
                new ServiceOutputMapping("Description", "Description", "dbo_Pr_CitiesGetCountries")
            };
            var oracleServerActivity = new DsfOracleDatabaseActivity
            {
                SourceId      = sourceId,
                ProcedureName = "dbo.Pr_CitiesGetCountries",
                Inputs        = inputs,
                Outputs       = outputs
            };
            var modelItem = ModelItemUtils.CreateModelItem(oracleServerActivity);
            var mockDatabaseInputViewModel = new Mock <IManageDatabaseInputViewModel>();
            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);

            _greenPointSource = new DbSourceDefinition
            {
                Name = "GreenPoint",
                Type = enSourceType.Oracle
            };

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

            _importOrderAction = new DbAction
            {
                Name   = "dbo.ImportOrder",
                Inputs = new List <IServiceInput> {
                    new ServiceInput("ProductId", "")
                }
            };

            _getCountriesAction = new DbAction {
                Name = "dbo.Pr_CitiesGetCountries"
            };
            _getCountriesAction.Inputs = inputs;
            var dbSources = new ObservableCollection <IDbSource> {
                _testingDbSource, _greenPointSource
            };

            mockDbServiceModel.Setup(model => model.RetrieveSources()).Returns(dbSources);
            mockDbServiceModel.Setup(model => model.GetActions(It.IsAny <IDbSource>())).Returns(new List <IDbAction> {
                _getCountriesAction, _importOrderAction
            });
            mockDatabaseInputViewModel.SetupAllProperties();
            var oracleDatabaseDesignerViewModel = new OracleDatabaseDesignerViewModel(modelItem, mockDbServiceModel.Object, new SynchronousAsyncWorker(), new ViewPropertyBuilder());

            ScenarioContext.Current.Add("viewModel", oracleDatabaseDesignerViewModel);
            ScenarioContext.Current.Add("mockDatabaseInputViewModel", mockDatabaseInputViewModel);
            ScenarioContext.Current.Add("mockDbServiceModel", mockDbServiceModel);
        }
Exemple #25
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);
        }