public void ReadShouldReadProjectFromXml() { StringBuilder bldr = new StringBuilder(); bldr.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>"); bldr.Append(@"<calidusproject>"); bldr.Append("<settings>"); bldr.Append(@"<IgnoreAssemblyFiles>true</IgnoreAssemblyFiles>"); bldr.Append(@"<IgnoreDesignerFiles>false</IgnoreDesignerFiles>"); bldr.Append(@"<IgnoreProgramFiles>true</IgnoreProgramFiles>"); bldr.Append("</settings>"); bldr.Append("<ignore>"); bldr.Append(@"<file path=""main\file1.cs"" />"); bldr.Append(@"<file path=""test\testfile.cs"" />"); bldr.Append("</ignore>"); bldr.Append("</calidusproject>"); IList <String> fileList = new List <String>(); fileList.Add(@"main\file1.cs"); fileList.Add(@"test\testfile.cs"); ICalidusProject expected = Mocker.StrictMock <ICalidusProject>(); Expect.Call(expected.IgnoreAssemblyFiles).Return(true).Repeat.Once(); Expect.Call(expected.IgnoreDesignerFiles).Return(false).Repeat.Once(); Expect.Call(expected.IgnoreProgramFiles).Return(true).Repeat.Once(); Expect.Call(expected.IgnoredFiles).Return(fileList).Repeat.Once(); Expect.Call(_rulesSectionManager.ReadFrom(null)).IgnoreArguments().Return(new IRuleConfigurationOverride[] {}).Repeat.Once(); Mocker.ReplayAll(); Stream source = new MemoryStream(); StreamWriter writer = new StreamWriter(source); writer.Write(bldr.ToString()); writer.Flush(); source.Position = 0; ICalidusProject actual = _manager.ReadFrom("test", new XmlTextReader(source)); Assert.AreEqual(expected.IgnoreAssemblyFiles, actual.IgnoreAssemblyFiles); Assert.AreEqual(expected.IgnoreDesignerFiles, actual.IgnoreDesignerFiles); Assert.AreEqual(expected.IgnoreProgramFiles, actual.IgnoreProgramFiles); CollectionAssert.AreEquivalent(expected.IgnoredFiles, actual.IgnoredFiles); Mocker.VerifyAll(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //get the project file StartUpWindow win = new StartUpWindow(); win.ShowDialog(); //if a file selected if (win.DialogResult == DialogResult.OK) { //build main objects CalidusProjectManager projectManager = new CalidusProjectManager(); CalidusProjectModel project = new CalidusProjectModel(projectManager.ReadFrom(win.SelectedProjectFile)); CalidusRuleConfigurationFactory configFactory = new CalidusRuleConfigurationFactory(project, projectManager); RuleRunner runner = new RuleRunner(); RuleViolationList violationList = new RuleViolationList(); //prepare main view MainWindow mainView = new MainWindow(); //assign controllers MainController c = new MainController(mainView, project, win.IsNewProject, projectManager, runner, violationList); ViolationListController violationListController = new ViolationListController(mainView.ViolationListView, project, violationList); CheckableRuleTreeController checkableRuleListController = new CheckableRuleTreeController(mainView.CheckableRuleTreeView, new CalidusRuleProvider(), configFactory); FileTreeController fileListController = new FileTreeController(mainView.FileListView, project); SourceLocationController sourceLocationController = new SourceLocationController(mainView.SourceLocationView, project); RuleRunnerController ruleRunnerController = new RuleRunnerController(mainView.RuleRunnerView, runner, project, configFactory); StatusController statusController = new StatusController(mainView.StatusView, violationList); //run application Application.Run(mainView); } }