public void AddsExpectedErrorTest()
        {
            var input = @"
Option Explicit
Option Private Module

'@TestModule

Private Assert As Object
{0}";

            IVBComponent component;
            var          vbe = MockVbeBuilder.BuildFromSingleStandardModule(string.Format(input, string.Empty), out component);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, state);

                addTestMethodCommand.Execute(null);
                var module = component.CodeModule;

                Assert.AreEqual(
                    string.Format(input,
                                  AddTestMethodExpectedErrorCommand.TestMethodExpectedErrorTemplate.Replace(AddTestMethodExpectedErrorCommand.NamePlaceholder,
                                                                                                            "TestMethod1")) + Environment.NewLine, module.Content());
            }
        }
Exemplo n.º 2
0
        public void AddsExpectedErrorTest_NullActiveCodePane()
        {
            var input =
                @"Option Explicit
Option Private Module


'@TestModule
Private Assert As Object
";

            var         builder = new MockVbeBuilder();
            VBComponent component;
            var         vbe = builder.BuildFromSingleStandardModule(input, out component);

            vbe.Setup(s => s.ActiveCodePane).Returns((CodePane)null);
            var mockHost = new Mock <IHostApplication>();

            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object));

            parser.Parse(new CancellationTokenSource());
            if (parser.State.Status >= ParserState.Error)
            {
                Assert.Inconclusive("Parser Error");
            }

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, parser.State);

            addTestMethodCommand.Execute(null);

            Assert.AreEqual(input, component.CodeModule.Lines());
        }
Exemplo n.º 3
0
        public void AddsExpectedErrorTest()
        {
            var input =
                @"Option Explicit
Option Private Module


'@TestModule
Private Assert As Object
{0}";

            var         builder = new MockVbeBuilder();
            VBComponent component;
            var         vbe      = builder.BuildFromSingleStandardModule(string.Format(input, string.Empty), out component);
            var         mockHost = new Mock <IHostApplication>();

            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object));

            parser.Parse(new CancellationTokenSource());
            if (parser.State.Status >= ParserState.Error)
            {
                Assert.Inconclusive("Parser Error");
            }

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, parser.State);

            addTestMethodCommand.Execute(null);

            Assert.AreEqual(
                string.Format(input,
                              AddTestMethodExpectedErrorCommand.TestMethodExpectedErrorTemplate.Replace(AddTestMethodExpectedErrorCommand.NamePlaceholder,
                                                                                                        "TestMethod1")) + Environment.NewLine, component.CodeModule.Lines());
        }
Exemplo n.º 4
0
        public void AddExpectedErrorTest_CanExecute_NoTestModule()
        {
            IVBComponent component;
            var          vbe   = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out component);
            var          state = MockParser.CreateAndParse(vbe.Object);

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, state);

            Assert.IsFalse(addTestMethodCommand.CanExecute(null));
        }
Exemplo n.º 5
0
        public void AddExpectedErrorTest_CanExecute_NonReadyState()
        {
            IVBComponent component;
            var          vbe = MockVbeBuilder.BuildFromSingleStandardModule(string.Empty, out component);

            var state = MockParser.CreateAndParse(vbe.Object);

            state.SetStatusAndFireStateChanged(this, ParserState.ResolvingReferences);

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, state);

            Assert.IsFalse(addTestMethodCommand.CanExecute(null));
        }
Exemplo n.º 6
0
        public TestExplorerViewModel(IVBE vbe,
                                     RubberduckParserState state,
                                     ITestEngine testEngine,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     IGeneralConfigService configService,
                                     ISettingsFormFactory settingsFormFactory,
                                     IMessageBox messageBox)
        {
            _vbe        = vbe;
            _state      = state;
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            Model                = model;
            _clipboard           = clipboard;
            _settingsFormFactory = settingsFormFactory;
            _messageBox          = messageBox;

            _navigateCommand = new NavigateCommand(_state.ProjectsProvider);

            RunAllTestsCommand = new RunAllTestsCommand(vbe, state, testEngine, model, null);
            RunAllTestsCommand.RunCompleted += RunCompleted;

            AddTestModuleCommand      = new AddTestModuleCommand(vbe, state, configService, _messageBox);
            AddTestMethodCommand      = new AddTestMethodCommand(vbe, state);
            AddErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, state);

            RefreshCommand              = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRefreshCommand, CanExecuteRefreshCommand);
            RepeatLastRunCommand        = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
            RunNotExecutedTestsCommand  = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
            RunInconclusiveTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunInconclusiveTestsCommand, CanExecuteRunInconclusiveTestsCommand);
            RunFailedTestsCommand       = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunFailedTestsCommand, CanExecuteRunFailedTestsCommand);
            RunPassedTestsCommand       = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunPassedTestsCommand, CanExecuteRunPassedTestsCommand);
            RunSelectedTestCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);

            CopyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand);

            OpenTestSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);

            SetOutcomeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByOutcome  = (bool)param;
                GroupByLocation = !(bool)param;
            });

            SetLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByLocation = (bool)param;
                GroupByOutcome  = !(bool)param;
            });
        }
Exemplo n.º 7
0
        public TestExplorerViewModel(VBE vbe,
                                     RubberduckParserState state,
                                     ITestEngine testEngine,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     NewUnitTestModuleCommand newTestModuleCommand,
                                     NewTestMethodCommand newTestMethodCommand,
                                     IGeneralConfigService configService,
                                     IOperatingSystem operatingSystem)
        {
            _state      = state;
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            _model           = model;
            _clipboard       = clipboard;
            _configService   = configService;
            _operatingSystem = operatingSystem;

            _navigateCommand = new NavigateCommand();

            _runAllTestsCommand = new RunAllTestsCommand(state, testEngine, model);
            _runAllTestsCommand.RunCompleted += RunCompleted;

            _addTestModuleCommand      = new AddTestModuleCommand(vbe, state, newTestModuleCommand);
            _addTestMethodCommand      = new AddTestMethodCommand(vbe, state, newTestMethodCommand);
            _addErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, state, newTestMethodCommand);

            _refreshCommand             = new DelegateCommand(ExecuteRefreshCommand, CanExecuteRefreshCommand);
            _repeatLastRunCommand       = new DelegateCommand(ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
            _runNotExecutedTestsCommand = new DelegateCommand(ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
            _runFailedTestsCommand      = new DelegateCommand(ExecuteRunFailedTestsCommand, CanExecuteRunFailedTestsCommand);
            _runPassedTestsCommand      = new DelegateCommand(ExecuteRunPassedTestsCommand, CanExecuteRunPassedTestsCommand);
            _runSelectedTestCommand     = new DelegateCommand(ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);

            _copyResultsCommand = new DelegateCommand(ExecuteCopyResultsCommand);

            _openTestSettingsCommand = new DelegateCommand(OpenSettings);

            _setOutcomeGroupingCommand = new DelegateCommand(param =>
            {
                GroupByOutcome  = (bool)param;
                GroupByLocation = !(bool)param;
            });

            _setLocationGroupingCommand = new DelegateCommand(param =>
            {
                GroupByLocation = (bool)param;
                GroupByOutcome  = !(bool)param;
            });
        }
Exemplo n.º 8
0
        public void AddExpectedErrorTest_CanExecute()
        {
            var input = @"
Option Explicit
Option Private Module

'@TestModule
Private Assert As Object
";

            IVBComponent component;
            var          vbe   = MockVbeBuilder.BuildFromSingleStandardModule(input, out component);
            var          state = MockParser.CreateAndParse(vbe.Object);

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, state);

            Assert.IsTrue(addTestMethodCommand.CanExecute(null));
        }
Exemplo n.º 9
0
        public void AddExpectedErrorTest_CanExecute_NoTestModule()
        {
            var         builder = new MockVbeBuilder();
            VBComponent component;
            var         vbe      = builder.BuildFromSingleStandardModule("", out component);
            var         mockHost = new Mock <IHostApplication>();

            mockHost.SetupAllProperties();
            var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object));

            parser.Parse(new CancellationTokenSource());
            if (parser.State.Status >= ParserState.Error)
            {
                Assert.Inconclusive("Parser Error");
            }

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, parser.State);

            Assert.IsFalse(addTestMethodCommand.CanExecute(null));
        }
Exemplo n.º 10
0
        public void AddsExpectedErrorTest_NullActiveCodePane()
        {
            var input = @"
Option Explicit
Option Private Module

'@TestModule
Private Assert As Object
";

            IVBComponent component;
            var          vbe = MockVbeBuilder.BuildFromSingleStandardModule(input, out component);

            vbe.Setup(s => s.ActiveCodePane).Returns((ICodePane)null);

            var state = MockParser.CreateAndParse(vbe.Object);

            var addTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe.Object, state);

            addTestMethodCommand.Execute(null);

            Assert.AreEqual(input, component.CodeModule.Content());
        }
        public TestExplorerViewModel(VBE vbe, ITestEngine testEngine, TestExplorerModelBase model, IClipboardWriter clipboard)
        {
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            _model     = model;
            _clipboard = clipboard;

            _navigateCommand = new NavigateCommand();

            _runAllTestsCommand        = new RunAllTestsCommand(testEngine, model);
            _addTestModuleCommand      = new AddTestModuleCommand(vbe);
            _addTestMethodCommand      = new AddTestMethodCommand(vbe, model);
            _addErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, model);

            _refreshCommand             = new DelegateCommand(ExecuteRefreshCommand, CanExecuteRefreshCommand);
            _repeatLastRunCommand       = new DelegateCommand(ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
            _runNotExecutedTestsCommand = new DelegateCommand(ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
            _runFailedTestsCommand      = new DelegateCommand(ExecuteRunFailedTestsCommand, CanExecuteRunFailedTestsCommand);
            _runPassedTestsCommand      = new DelegateCommand(ExecuteRunPassedTestsCommand, CanExecuteRunPassedTestsCommand);
            _runSelectedTestCommand     = new DelegateCommand(ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);

            _copyResultsCommand = new DelegateCommand(ExecuteCopyResultsCommand);
        }
Exemplo n.º 12
0
 public AddTestMethodExpectedErrorCommandMenuItem(AddTestMethodExpectedErrorCommand command)
     : base(command)
 {
 }