Ejemplo n.º 1
0
        public void ComDllViewModel_GenerateOutputsVisible_Set_SetsOtherProperties()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItem(), ps.Object);

            vm.ManageServiceInputViewModel.InputArea.IsEnabled  = false;
            vm.ManageServiceInputViewModel.OutputArea.IsEnabled = false;
            //------------Assert Results-------------------------
            vm.GenerateOutputsVisible = true;

            Assert.IsTrue(vm.GenerateOutputsVisible);
            Assert.IsTrue(vm.ManageServiceInputViewModel.InputArea.IsEnabled);
            Assert.IsFalse(vm.ManageServiceInputViewModel.OutputArea.IsEnabled);

            vm.GenerateOutputsVisible = false;
            Assert.IsFalse(vm.GenerateOutputsVisible);
            Assert.IsFalse(vm.ManageServiceInputViewModel.InputArea.IsEnabled);
            Assert.IsFalse(vm.ManageServiceInputViewModel.OutputArea.IsEnabled);
        }
Ejemplo n.º 2
0
        public void GivenIDragComdllToolOntoTheDesignSurface()
        {
            var comDllActivity = new DsfComDllActivity();

            comDllActivity.SourceId = new Guid("f9c016b6-9db4-4971-9634-60295bfc546f");
            var dataObject  = new Mock <IDSFDataObject>();
            var channel     = new Mock <IEsbChannel>();
            var environment = new Mock <IExecutionEnvironment>();
            var errors      = new HashSet <string>();

            environment.SetupGet(executionEnvironment => executionEnvironment.Errors).Returns(errors);
            dataObject.Setup(dObj => dObj.Environment).Returns(environment.Object);
            dataObject.Setup(dObj => dObj.EsbChannel).Returns(channel.Object);
            dataObject.SetupGet(dObj => dObj.WorkspaceID).Returns(Guid.NewGuid);
            var modelItem          = ModelItemUtils.CreateModelItem(comDllActivity);
            var pluginServiceModel = new Mock <IComPluginServiceModel>();
            var plugInSources      = new Mock <ObservableCollection <IComPluginSource> >();

            pluginServiceModel.Setup(serviceModel => serviceModel.RetrieveSources())
            .Returns(plugInSources.Object);
            var viewModel     = new ComDllViewModel(modelItem, pluginServiceModel.Object);
            var privateObject = new PrivateObject(comDllActivity);

            _scenarioContext.Add("ViewModel", viewModel);
            _scenarioContext.Add("DataObject", dataObject.Object);
            _scenarioContext.Add("Channel", channel);
            _scenarioContext.Add("Environment", environment.Object);
            _scenarioContext.Add("Model", pluginServiceModel);
            _scenarioContext.Add("Activity", comDllActivity);
            _scenarioContext.Add("PrivateObj", privateObject);
            _scenarioContext.Add("PlugInSources", plugInSources);
        }
Ejemplo n.º 3
0
        public void ComDllViewModel_UpdateWorstDesignError()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            vm.DesignValidationErrors.Add(new ErrorInfo()
            {
                Message = "bob error", ErrorType = ErrorType.Critical
            });
            var p = new PrivateObject(vm);

            p.Invoke("UpdateWorstError");
            var inf = vm.WorstDesignError as ErrorInfo;

            //------------Assert Results-------------------------

            Assert.IsNotNull(inf);
            Assert.AreEqual("bob error", inf.Message);
        }
Ejemplo n.º 4
0
 public MyActivity(IDSFDataObject dsfDataObject, ComDllViewModel vm, DsfComDllActivity act)
 {
     OutputDescription = new OutputDescription();
     Outputs           = new List <IServiceOutputMapping>();
     Inputs            = new List <IServiceInput>();
     SourceId          = vm.SourceRegion.SelectedSource.Id;
     _dsfDataObject    = dsfDataObject;
     ResourceID        = Guid.NewGuid();
     Method            = vm.ActionRegion.SelectedAction;
 }
Ejemplo n.º 5
0
        public void ComDllViewModel_Test()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            vm.TestProcedure();
            //------------Assert Results-------------------------
        }
Ejemplo n.º 6
0
        public void ComDllViewModel_Validate_HasErrorsIfNoSource()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------
            var vm = new ComDllViewModel(CreateModelItem(), ps.Object);

            //------------Assert Results-------------------------
            vm.Validate();

            Assert.AreEqual(1, vm.Errors.Count);
        }
Ejemplo n.º 7
0
        public void ComDllViewModel_FixErrors()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            //------------Assert Results-------------------------
            vm.FixErrorsCommand.Execute(null);
            Assert.IsTrue(vm.IsWorstErrorReadOnly);
        }
Ejemplo n.º 8
0
        public void ComDllViewModel_ClearValidationMessage()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            //------------Assert Results-------------------------
            vm.ClearValidationMemoWithNoFoundError();
            Assert.AreEqual(vm.DesignValidationErrors[0].Message, String.Empty);
        }
Ejemplo n.º 9
0
        public void ComDllViewModel_ErrorMessage()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            //------------Assert Results-------------------------
            vm.ErrorMessage(new AccessViolationException("bob"), true);
            Assert.IsTrue(vm.Errors.Count > 0);
            Assert.AreEqual("bob", vm.Errors[0].Message);
        }
Ejemplo n.º 10
0
        public void ComDllViewModel_UpdateHelp_ShouldCallToHelpViewMode()
        {
            //------------Setup for test--------------------------
            var mockMainViewModel = new Mock <IShellViewModel>();
            var mockHelpViewModel = new Mock <IHelpWindowViewModel>();

            mockHelpViewModel.Setup(model => model.UpdateHelpText(It.IsAny <string>())).Verifiable();
            mockMainViewModel.Setup(model => model.HelpViewModel).Returns(mockHelpViewModel.Object);
            CustomContainer.Register(mockMainViewModel.Object);

            var ps        = SetupEmptyMockSource();
            var viewModel = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            //------------Execute Test---------------------------
            viewModel.UpdateHelpDescriptor("help");
            //------------Assert Results-------------------------
            mockHelpViewModel.Verify(model => model.UpdateHelpText(It.IsAny <string>()), Times.Once());
        }
Ejemplo n.º 11
0
        public void ComDllViewModel_SetDisplayName()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------

            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object);

            //------------Assert Results-------------------------
            vm.SetDisplayName("dsfbob_builer");
            var p = new PrivateObject(vm);

            Assert.AreEqual(p.GetProperty("DisplayName"), "Com DLLdsfbob_builer");
        }
Ejemplo n.º 12
0
        public void BuildRegions_GivenNamespacesRegionHasErrors_ShouldhaveErrors()
        {
            //---------------Set up test pack-------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);

            var ps = new Mock <IComPluginServiceModel>();

            ps.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IComPluginSource>()
            {
                new ComPluginSourceDefinition()
                {
                    Id = id
                }
            });
            ps.Setup(a => a.GetNameSpaces(It.IsAny <IComPluginSource>())).Throws(new BadImageFormatException());
            ps.Setup(a => a.GetActions(It.IsAny <IComPluginSource>(), It.IsAny <INamespaceItem>())).Returns(new ObservableCollection <IPluginAction>()
            {
                new PluginAction()
                {
                    FullName = "bob", Inputs = new List <IServiceInput>()
                }
            });

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var vm = new ComDllViewModel(CreateModelItemWithValues(), ps.Object)
            {
                SourceRegion = null
            };
            var buildRegions = vm.BuildRegions();

            //---------------Test Result -----------------------
            Assert.AreEqual(buildRegions.Single(region => region is INamespaceToolRegion <INamespaceItem>).Errors.Count, 1);
        }
Ejemplo n.º 13
0
        public void ComDllViewModel_Constructor_Valid_ShouldSetupViewModel()
        {
            //------------Setup for test--------------------------
            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(model => model.ActiveServer).Returns(new ServerForTesting(new Mock <IExplorerRepository>()));
            CustomContainer.Register(mockShellViewModel.Object);
            var ps = SetupEmptyMockSource();
            //------------Execute Test---------------------------
            var vm = new ComDllViewModel(CreateModelItem(), ps.Object);

            //------------Assert Results-------------------------
            Assert.IsNotNull(vm);
            Assert.IsNotNull(vm.ModelItem);
            Assert.IsTrue(vm.HasLargeView);
            Assert.IsNotNull(vm.ManageServiceInputViewModel);
            Assert.AreEqual(46, vm.LabelWidth);
            Assert.AreEqual("Done", vm.ButtonDisplayValue);
            Assert.IsTrue(vm.ShowLarge);
            Assert.AreEqual(Visibility.Visible, vm.ThumbVisibility);
            Assert.AreEqual(Visibility.Collapsed, vm.ShowExampleWorkflowLink);
            Assert.IsNotNull(vm.DesignValidationErrors);
            Assert.IsNotNull(vm.FixErrorsCommand);
            Assert.IsNotNull(vm.SourceRegion);
            Assert.IsNotNull(vm.NamespaceRegion);
            Assert.IsNotNull(vm.ActionRegion);
            Assert.IsNotNull(vm.InputArea);
            Assert.IsNotNull(vm.OutputsRegion);
            Assert.IsNotNull(vm.ErrorRegion);
            Assert.IsNotNull(vm.Regions);
            Assert.AreEqual(7, vm.Regions.Count);
            Assert.IsTrue(vm.OutputsRegion.OutputMappingEnabled);
            Assert.IsNotNull(vm.TestInputCommand);
            Assert.IsNotNull(vm.Properties);
            Assert.AreEqual(1, vm.Properties.Count);
        }