Example #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);
        }
Example #2
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);
        }
Example #3
0
        public void BrowseCodeTemplateCommandExecute_ShouldAddNewUserCodeTemplate()
        {
            //Arange
            string currentFilePath   = AppDomain.CurrentDomain.BaseDirectory;
            string amlMethodFilePath = Path.Combine(currentFilePath, @"Code\TestData\MethodAml\ReturnNullMethodAml.xml");

            this.codeProvider.Language.Returns("C#");

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

            this.dialogFactory.GetOpenFileDialog("XML Files (*.xml)|*.xml", "xml").Returns(openFileDialog);
            int userCodeTemplateCount = this.createMethodViewModel.UserCodeTemplates.Count;

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

            //Assert

            this.globalConfiguration.Received().AddUserCodeTemplatePath(amlMethodFilePath);
            Assert.AreEqual(1, this.createMethodViewModel.UserCodeTemplates.Count - userCodeTemplateCount);
            Assert.IsNotNull(this.createMethodViewModel.SelectedUserCodeTemplate);
        }