public void TestEditor_WhenOpened_DisplaysTestCaseContent(string path) { DefaultSetup(); _presenter.FilePath = path; _fileBrowser.ShowDialog().Returns(true); _fileBrowser.FileName.Returns(Assembly.GetAssembly(typeof(TestServiceTests)).GetName().Name + ".dll"); _view.AddTreeNode(Arg.Any <string>()).Returns(new TreeNode()); _presenter.ShowView(); _fileService.Received(String.IsNullOrEmpty(path) ? 0 : 2).GetLines(path); _view.TestCaseLines.Should().HaveCount(String.IsNullOrEmpty(path) ? 0 : 3); }
public BadgerTestEditorTests() { _view = Substitute.For <ITestEditorView>(); _view.AddTreeNode(Arg.Any <string>()).Returns(new TreeNode()); _view.When(v => v.ShowDialog()).Do(x => _view.OnFormLoad += Raise.EventWith(null, EventArgs.Empty)); _fileService = Substitute.For <IFileService>(); _messageBox = Substitute.For <IMessageBoxService>(); _fileBrowser = Substitute.For <IFileBrowser>(); _fileService.GetLines(Arg.Any <string>()).Returns(new List <string>() { "Line1", "Line2" }); _presenter = new BadgerTestEditorPresenter(_view, _fileService, _messageBox, _fileBrowser); }
private void BuildTestStepTree() { var root = _view.AddTreeNode("Steps"); if (StepClasses != null) { foreach (var stepClass in StepClasses) { TreeNode t = new TreeNode(stepClass.GetCustomAttribute <StepsAttribute>().Text); var methods = stepClass.GetMethods() .Where(m => Attribute.IsDefined(m, typeof(StepAttribute))).ToList(); foreach (var method in methods) { TreeNode node = new TreeNode(); node.Text = method.GetCustomAttribute <StepAttribute>().Text; node.Tag = method; t.Nodes.Add(node); } root.Nodes.Add(t); } } }