public CogProject GetDefaultProject() { var spanFactory = new ShapeSpanFactory(); var segmentPool = new SegmentPool(); return(VerbBase.GetProjectFromResource(spanFactory, segmentPool)); }
public void SetupProject_WithNoConfigFile_ShouldLoadDefaultProject() { var options = new VerbBase(); options.SetupProject(); CheckDoesNotHaveTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(17)); }
private static void RunVerbLifecycle(VerbBase verb) { var currentTimeTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} "; var template = "[{Level:u3}<{TaskId}>@{SourceContext}] {Message:lj} {NewLine}{Exception}"; Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithDemystifiedStackTraces() .Enrich.WithThreadId() .Enrich.WithThreadName() .Enrich.With <TaskIdEnricher>() .MinimumLevel.Is(verb.LogLevel) .WriteTo.Console(outputTemplate: template) .WriteTo.File("smacd.log", outputTemplate: currentTimeTemplate + template) .CreateLogger(); Extensions.LogFactory.AddSerilog(); if (!verb.Silent) { TerminalEffects.DrawLogoBanner(); } var runningTask = verb.Execute(); if (runningTask != null) { while (!runningTask.IsCompleted) { Thread.Sleep(100); } if (runningTask.Exception != null) { if (runningTask.Exception is AggregateException) { foreach (var item in runningTask.Exception.InnerExceptions) { Logger.LogCritical(item, "Error running task"); } } else { Logger.LogCritical(runningTask.Exception, "Error running task"); } } Logger.LogDebug("Application complete"); } }
public void SetupProject_WithFilename_ShouldLoadThatFile() { CogProject project = GetTestProject(); string filename = Path.GetTempFileName(); try { SaveProject(project, filename); var options = new VerbBase(); options.ConfigFilename = filename; options.SetUpProject(); CheckHasTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(18)); } finally { File.Delete(filename); } }
public void SetupProject_WithFilename_ShouldLoadThatFile() { CogProject project = GetTestProject(); string filename = Path.GetTempFileName(); try { SaveProject(project, filename); var options = new VerbBase { ConfigFilename = filename }; options.SetupProject(); CheckHasTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(18)); } finally { File.Delete(filename); } }
public void SetupProject_WithXmlString_ShouldLoadThatXml() { CogProject project = GetTestProject(); string filename = Path.GetTempFileName(); try { SaveProject(project, filename); string xmlString = File.ReadAllText(filename, Encoding.UTF8); var options = new VerbBase { ConfigData = xmlString }; options.SetupProject(); CheckHasTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(18)); } finally { File.Delete(filename); } }
public void CheckVerbOutput(string input, string expectedOutput, string expectedErrors, VerbBase verbUnderTest, bool stripNewlines) { var inputStream = new StringReader(input); var outputStream = new StringWriter(); var errorStream = new StringWriter(); var retcode = verbUnderTest.DoWorkWithErrorChecking(inputStream, outputStream, errorStream); string TextResult = outputStream.ToString().Replace("\r\n", "\n"); string ErrorText = errorStream.ToString().Replace("\r\n", "\n"); if (stripNewlines) TextResult = TextResult.Replace("\n", ""); Assert.That(TextResult, Is.EqualTo(expectedOutput)); if (expectedErrors == null) { Assert.That(ErrorText, Is.EqualTo("")); Assert.That(retcode, Is.EqualTo(ReturnCodes.Okay)); } else { Assert.That(ErrorText, Is.EqualTo(expectedErrors)); Assert.That(retcode, Is.Not.EqualTo(ReturnCodes.Okay)); } }
public void CheckVerbOutput(string input, string expectedOutput, VerbBase verbUnderTest, bool stripNewlines) { CheckVerbOutput(input, expectedOutput, null, verbUnderTest, stripNewlines); }
public void CheckVerbOutput(string input, string expectedOutput, VerbBase verbUnderTest) { CheckVerbOutput(input, expectedOutput, verbUnderTest, true); }
public CogProject GetDefaultProject() { var segmentPool = new SegmentPool(); return(VerbBase.GetProjectFromResource(segmentPool)); }
private XElement CreateXmlFromVerb(VerbBase verb) { // Create the verb node. var node = new XElement(verb.Name); // Add the value if present. if (!string.IsNullOrWhiteSpace(verb.Value)) node.Value = verb.Value; // Add any attributes that aren't empty. foreach (var keyVal in verb.Attributes) { if (!string.IsNullOrWhiteSpace(keyVal.Value)) node.Add(new XAttribute(keyVal.Key, keyVal.Value)); } return node; }
public void CheckVerbOutput(string input, string expectedOutput, string expectedErrors, VerbBase verbUnderTest, bool stripNewlines) { var inputStream = new StringReader(input); var outputStream = new StringWriter(); var errorStream = new StringWriter(); var retcode = verbUnderTest.DoWorkWithErrorChecking(inputStream, outputStream, errorStream); string TextResult = outputStream.ToString().Replace("\r\n", "\n"); string ErrorText = errorStream.ToString().Replace("\r\n", "\n"); if (stripNewlines) { TextResult = TextResult.Replace("\n", ""); } Assert.That(TextResult, Is.EqualTo(expectedOutput)); if (expectedErrors == null) { Assert.That(ErrorText, Is.EqualTo("")); Assert.That(retcode, Is.EqualTo(ReturnCode.Okay)); } else { Assert.That(ErrorText, Is.EqualTo(expectedErrors)); Assert.That(retcode, Is.Not.EqualTo(ReturnCode.Okay)); } }
public void SetupProject_WithXmlString_ShouldLoadThatXml() { CogProject project = GetTestProject(); string filename = Path.GetTempFileName(); try { SaveProject(project, filename); string xmlString = File.ReadAllText(filename, Encoding.UTF8); var options = new VerbBase(); options.ConfigData = xmlString; options.SetUpProject(); CheckHasTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(18)); } finally { File.Delete(filename); } }
public void SetupProject_WithNoConfigFile_ShouldLoadDefaultProject() { var options = new VerbBase(); options.SetUpProject(); CheckDoesNotHaveTestFeature(options.Project); Assert.That(options.Project.FeatureSystem.Count, Is.EqualTo(17)); }