public void ManageDatabaseServiceInputViewModel_WithOneColumn_TestActionSetSourceAndTestClickOk()
        {
            //------------Setup for test--------------------------
            var mod = new SqlServerModelWithOneColumnReturn();

            var act = new DsfSqlServerDatabaseActivity();

            var sqlServer = new SqlServerDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker(), new ViewPropertyBuilder());
            var inputview = new ManageDatabaseServiceInputViewModel(sqlServer, mod);

            inputview.Model = new DatabaseService()
            {
                Source = new DbSourceDefinition(), Action = new DbAction()
                {
                    Inputs = new List <IServiceInput>(), Name = "bob"
                },
            };
            inputview.TryExecuteTest();
            //------------Execute Test---------------------------

            Assert.IsTrue(inputview.TestPassed);
            Assert.IsFalse(inputview.TestFailed);
            Assert.AreEqual(string.Empty, inputview.TestMessage);
            Assert.IsFalse(inputview.ShowTestMessage);
            inputview.ExecuteOk();
            //------------Execute Ok---------------------------
            Assert.IsTrue(sqlServer.SourceRegion.IsEnabled);
            Assert.IsTrue(sqlServer.InputArea.IsEnabled);
            Assert.IsTrue(sqlServer.OutputsRegion.IsEnabled);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, sqlServer.OutputsRegion.Outputs.Count);
        }
        public void ManageDatabaseServiceInputViewModel_PropertyChangedHandler()
        {
            //------------Setup for test--------------------------
            var mod = new SqlServerModel();

            var act       = new DsfSqlServerDatabaseActivity();
            var called    = false;
            var sqlServer = new SqlServerDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker(), new ViewPropertyBuilder());
            var inputview = new ManageDatabaseServiceInputViewModel(sqlServer, mod);

            inputview.PropertyChanged += (sender, args) => called = true;
            inputview.Model            = new DatabaseService();
            //------------Execute Test---------------------------
            inputview.TryExecuteTest();

            //------------Assert Results-------------------------
            Assert.IsTrue(called);
        }
        public void ManageDatabaseServiceInputViewModelTestAction_Exception()
        {
            //------------Setup for test--------------------------
            var mod = new SqlServerModel()
            {
                ThrowsTestError = true
            };

            mod.HasRecError = true;

            var act       = new DsfSqlServerDatabaseActivity();
            var sqlServer = new SqlServerDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker(), new ViewPropertyBuilder());
            var inputview = new ManageDatabaseServiceInputViewModel(sqlServer, mod);

            inputview.Model = null;

            //------------Execute Test---------------------------
            inputview.TryExecuteTest();

            //------------Assert Results-------------------------
            Assert.IsTrue(inputview.Errors.Count == 1);
        }
        public void ManageDatabaseServiceInputViewModel_TestActionSetSourceAndReturnNoDataMessage()
        {
            //------------Setup for test--------------------------
            var mod = new SqlServerModel();

            mod.ReturnsNoColumns = true;
            var act       = new DsfSqlServerDatabaseActivity();
            var sqlServer = new SqlServerDatabaseDesignerViewModel(ModelItemUtils.CreateModelItem(act), mod, new SynchronousAsyncWorker(), new ViewPropertyBuilder());
            var inputview = new ManageDatabaseServiceInputViewModel(sqlServer, mod);

            inputview.Model = new DatabaseService()
            {
                Source = new DbSourceDefinition(), Action = new DbAction()
                {
                    Inputs = new List <IServiceInput>(), Name = ""
                },
            };
            inputview.TryExecuteTest();

            Assert.IsTrue(inputview.TestPassed);
            Assert.IsFalse(inputview.TestFailed);
            Assert.AreEqual("No data returned.   ", inputview.TestMessage);
            Assert.IsTrue(inputview.ShowTestMessage);
        }