Ejemplo n.º 1
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 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.º 3
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.º 4
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);
        }