// ReSharper disable once UnusedMember.Local private int OnExecute() { ITestResultsOutputWriterFactory outputWriterFactory = new DefaultTestResultsOutputWriterFactory(); using (ITestResultsOutputWriter outputWriter = outputWriterFactory.Create(Output)) { OutputTemplateManager outputTemplateManager = new OutputTemplateManager(Path, new TestRunResultParser(Format), new DefaultFileSystemManager()); IOutputTemplateFactory outputTemplateFactory = outputTemplateManager.CreateOutputTemplateFactory(); IOutputTemplate outputTemplate = OutputTemplateManager.CreateOutputTemplate(outputTemplateFactory, Template); outputTemplate.Write(outputWriter); if (FailWhenResultIsFailed && !outputTemplateFactory.IsSuccess) { return(-1); } } return(0); }
public void CreateOutputTemplate(OutputTemplateType outputTemplateType) { // Arrange IOutputTemplateFactory outputTemplateFactory = Substitute.For <IOutputTemplateFactory>(); // Act OutputTemplateManager.CreateOutputTemplate(outputTemplateFactory, outputTemplateType); // Assert if (outputTemplateType == OutputTemplateType.Summary) { outputTemplateFactory.Received(1).CreateSummaryOutputTemplate(); outputTemplateFactory.Received(0).CreateTestResultOutputTemplate(); } else if (outputTemplateType == OutputTemplateType.TestResult) { outputTemplateFactory.Received(0).CreateSummaryOutputTemplate(); outputTemplateFactory.Received(1).CreateTestResultOutputTemplate(); } }
public void CreateOutputTemplate_ShouldThrowArgumentOutOfRange_WhenOutputTemplateTypeIsNone() { // Arrange IOutputTemplateFactory outputTemplateFactory = Substitute.For <IOutputTemplateFactory>(); // Act ArgumentOutOfRangeException argumentOutOfRangeException = Assert.Throws <ArgumentOutOfRangeException>(() => OutputTemplateManager.CreateOutputTemplate(outputTemplateFactory, OutputTemplateType.None)); // Assert Assert.AreEqual($"Exception of type 'System.ArgumentOutOfRangeException' was thrown.{Environment.NewLine}Parameter name: outputTemplateType{Environment.NewLine}Actual value was None.", argumentOutOfRangeException.Message); }