public void CanGenerateOutput() { var scenario = new SbeScenario { Title = "Scenario Title", Outcome = Outcome.Passed }; var feature = new SbeFeature(title: "Feature Title", scenarios: new[] { scenario }); var collectedTests = new SbeAssembly[] { new SbeAssembly( name: "some.strange.assembly", epics: new[] { new SbeEpic(name: "Some Epic", features: new[] { feature }) }) }; string outputFileName = null; string outputContent = null; var generator = new JsonSummaryGenerator((file, json) => { outputFileName = file; outputContent = json; }); generator.Generate(collectedTests); Assert.That(outputFileName, Is.EqualTo("\\some.strange.assembly.summary.sbe.json"), "FileName"); var output = JObject.Parse(outputContent); Assert.That(output["epics"].HasValues, Is.True, "Should contain epics"); }
private static SbeAssembly GetCurrentAssembly(string assemblyName) { if (!Assemblies.TryGetValue(assemblyName, out SbeAssembly assembly)) { assembly = new SbeAssembly { Name = assemblyName, }; Assemblies.Add(assemblyName, assembly); } return(assembly); }
private static SbeEpic GetCurrentEpic(SbeAssembly assembly, SpecflowContextWrapper specflowContext) { var epicName = specflowContext.GetEpicName(); if (!assembly.Epics.TryGetValue(epicName, out SbeEpic epic)) { epic = new SbeEpic { Name = epicName, }; assembly.Epics.Add(epicName, epic); } return(epic); }
public void CanGeneratePdf() { var scenario = new SbeScenario { Title = "Scenario Title", Outcome = Outcome.Passed }; var feature = new SbeFeature(title: "Feature Title", scenarios: new[] { scenario }); feature.FeatureText = @"@current Feature: Implemented Feature Some description Scenario: Add two numbers for implemented calculator Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen" ; var collectedTests = new SbeAssembly[] { new SbeAssembly( name: "some.strange.assembly", epics: new[] { new SbeEpic(name: "Some Epic", features: new[] { feature }) }) }; string outputFileName = null; byte[] outputContent = null; var generator = new PdfGenerator("testing", OutputFilter.All, (file, bytes) => { outputFileName = file; outputContent = bytes; }); generator.Generate(collectedTests); Assert.That(outputFileName, Is.EqualTo("\\some.strange.assembly.testing.sbe.pdf"), "FileName"); var firstFourBytes = Convert.ToBase64String(outputContent.Take(4).ToArray()); Assert.That(firstFourBytes, Is.EqualTo("JVBERg==")); }
private static string GetJson(SbeAssembly assembly) { var outputModel = new { epics = assembly.GetEpics() .Select(e => new { e.Name, Features = e.GetFeatures() .Select(x => new { x.Title, x.Tags, Success = x.Success(), Scenarios = x.Scenarios.Select(s => new { s.Title, Success = s.Success(), Outcome = s.Outcome.ToString(), s.Tags }) }) }) }; var json = JsonConvert.SerializeObject(outputModel, Formatting.Indented); return(json); }