public void SaveDirtyFiles_ShouldReturnTrue()
        {
            //Arange
            InitTestprojectStructure();
            this.mainMethodFileProjectItem.IsDirty.Returns(true);

            IVsUIShell vsUIShell = Substitute.For <IVsUIShell>();

            this.serviceProvider.GetService(typeof(SVsUIShell)).Returns(vsUIShell);

            IMessageBoxWindow messageBoxWindow = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBoxWindow);
            messageBoxWindow.ShowDialog("One or more method files is not saved. Do you want to save changes?",
                                        "Aras VS method plugin",
                                        MessageButtons.YesNoCancel,
                                        MessageIcon.Question).Returns(MessageDialogResult.No);

            MethodInfo methodInfo = new MethodInfo()
            {
                MethodName     = "TestMethodName",
                PartialClasses = new List <string>(),
                ExternalItems  = new List <string>()
            };

            List <MethodInfo> methodInfos = new List <MethodInfo>();

            methodInfos.Add(methodInfo);

            //Act
            bool result = this.projectManager.SaveDirtyFiles(methodInfos);

            //Assert
            Assert.IsTrue(result);
        }
Ejemplo n.º 2
0
        public void OpenMethodFromAras(string openRequestString)
        {
            OpenMethodContext openContext = openContextParser.Parse(openRequestString);

            if (openContext == null)
            {
                return;
            }

            IMessageBoxWindow   messageBox = dialogFactory.GetMessageBoxWindow();
            MessageDialogResult result     = messageBox.ShowDialog(messageManager.GetMessage("CreateNewOrOpenExistingProject"),
                                                                   messageManager.GetMessage("ArasVSMethodPlugin"), MessageButtons.YesNo, MessageIcon.Question);

            if (result == MessageDialogResult.Yes)
            {
                projectManager.ExecuteCommand("File.NewProject");
            }
            else
            {
                projectManager.ExecuteCommand("File.OpenProject");
            }

            if (projectManager.SolutionHasProject && projectManager.IsArasProject)
            {
                Commands.OpenFromArasCmd.Instance.ExecuteCommand(this, openContext);
            }
        }
Ejemplo n.º 3
0
        public void BrowseCodeTemplateCommandExecute_ShouldShowExpectedMessageee()
        {
            //Arange
            string currentFilePath   = AppDomain.CurrentDomain.BaseDirectory;
            string amlMethodFilePath = Path.Combine(currentFilePath, @"Code\TestData\MethodAml\ReturnNullMethodAml.xml");

            this.codeProvider.Language.Returns("VB");

            OpenFileDialogTestAdapter openFileDialog = new OpenFileDialogTestAdapter(DialogResult.OK, amlMethodFilePath);

            this.dialogFactory.GetOpenFileDialog("XML Files (*.xml)|*.xml", "xml").Returns(openFileDialog);

            IMessageBoxWindow messageBox = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBox);

            //Act
            this.createMethodViewModel.BrowseCodeTemplateCommand.Execute(null);

            //Assert
            messageBox.Received().ShowDialog($"User code tamplate must be {this.codeProvider.Language} method type.",
                                             "Warning",
                                             MessageButtons.OK,
                                             MessageIcon.Warning);
        }
        public void SaveDirtyFiles_ShouldReturnTrue()
        {
            //Arange
            InitTestprojectStructure();
            this.mainMethodFileProjectItem.IsDirty.Returns(true);

            IVsUIShell vsUIShell = Substitute.For <IVsUIShell>();

            this.serviceProvider.GetService(typeof(SVsUIShell)).Returns(vsUIShell);

            IMessageBoxWindow messageBoxWindow = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBoxWindow);
            messageBoxWindow.ShowDialog(messageManager.GetMessage("OneOrMoreMethodFilesIsNotSavedDoYouWantToSaveChanges"),
                                        messageManager.GetMessage("ArasVSMethodPlugin"),
                                        MessageButtons.YesNoCancel,
                                        MessageIcon.Question).Returns(MessageDialogResult.No);

            MethodInfo methodInfo = new MethodInfo()
            {
                MethodName = "TestMethodName"
            };

            List <MethodInfo> methodInfos = new List <MethodInfo>();

            methodInfos.Add(methodInfo);

            //Act
            bool result = this.projectManager.SaveDirtyFiles(this.dialogFactory, methodInfos);

            //Assert
            Assert.IsTrue(result);
        }
Ejemplo n.º 5
0
        public override void ExecuteCommandImpl(object sender, EventArgs args)
        {
            dynamic result = authManager.InnovatorInstance.applyAML(Properties.Resources.ImportOpenInVSActionAML);

            IMessageBoxWindow messageBox = dialogFactory.GetMessageBoxWindow();
            string            title      = messageManager.GetMessage("ArasVSMethodPlugin");

            if (result.isError())
            {
                string errorMessage = messageManager.GetMessage("OpenInVSActionImportFailed", result.getErrorString());
                messageBox.ShowDialog(errorMessage, title, MessageButtons.OK, MessageIcon.Error);
            }
            else
            {
                messageBox.ShowDialog(messageManager.GetMessage("OpenInVSActionImported"), title, MessageButtons.OK, MessageIcon.Information);
            }
        }
        public void GetTemplateFromCodeString_ShouldShowMessageAndReturnExpected()
        {
            //Arange
            var currentPath      = System.AppDomain.CurrentDomain.BaseDirectory;
            var methodConfigPath = Path.Combine(currentPath, @"Templates\TestData\method-config.xml");

            templateLoader.Load(methodConfigPath);
            string            testCode         = "//MethodTemplateName=templateName";
            IMessageBoxWindow messageBoxWindow = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBoxWindow);
            TemplateInfo expectedtemplate = LoadExpectedtemplates()[2];

            //Act
            TemplateInfo actualTemplate = templateLoader.GetTemplateFromCodeString(testCode, "C#", "operationName");

            //Assert
            messageBoxWindow.Received().ShowDialog(Arg.Any <string>(), "operationName", MessageButtons.OK, MessageIcon.Information);
            Assert.IsTrue(IsSameTemplates(expectedtemplate, actualTemplate));
        }
Ejemplo n.º 7
0
        public void SelectedTemplate_ShouldReceiveMessageBox()
        {
            //Arange
            TemplateInfo testTemplateInfo = new TemplateInfo()
            {
                Message = "messageText",
                IsSuccessfullySupported = false
            };

            IMessageBoxWindow messageBox = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBox);
            //Act
            this.openFromArasViewModel.SelectedTemplate = testTemplateInfo;

            //Assert
            messageBox.Received().ShowDialog(testTemplateInfo.Message,
                                             "Open method Aras Innovator",
                                             MessageButtons.OK,
                                             MessageIcon.None);
        }
Ejemplo n.º 8
0
        public void BrowseCodeTemplateCommandExecute_ShouldShowTemplateInvalidMessage()
        {
            //Arange
            string filePath = "filePathTest";
            OpenFileDialogTestAdapter openFileDialog = new OpenFileDialogTestAdapter(DialogResult.OK, filePath);

            this.dialogFactory.GetOpenFileDialog("XML Files (*.xml)|*.xml", "xml").Returns(openFileDialog);

            IMessageBoxWindow messageBox = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBox);

            //Act
            this.createMethodViewModel.BrowseCodeTemplateCommand.Execute(null);

            //Assert
            messageBox.Received().ShowDialog($"User code template invalid format.",
                                             "Warning",
                                             MessageButtons.OK,
                                             MessageIcon.Warning);
        }
        public void SetValueInSelectedTemplate_ShouldReceiveExpectedMessage()
        {
            //Arange
            TemplateInfo testTemplateInfo = new TemplateInfo()
            {
                Message = "Message",
                IsSuccessfullySupported = false
            };

            IMessageBoxWindow messageBoxWindow = Substitute.For <IMessageBoxWindow>();

            this.dialogFactory.GetMessageBoxWindow().Returns(messageBoxWindow);

            //Act
            this.openFromPackageViewModel.SelectedTemplate = testTemplateInfo;

            //Assert
            messageBoxWindow.Received().ShowDialog("Message",
                                                   messageManager.GetMessage("OpenMethodFromAMLPackage"),
                                                   MessageButtons.OK,
                                                   MessageIcon.None);
        }