public void Should_Throw_If_TemplatePath_Is_Null() { // Given FilePath templatePath = null; // When var result = Record.Exception(() => GenericIssueReportFormatSettings.FromFilePath(templatePath)); // Then result.IsArgumentNullException("templatePath"); }
public void Should_Read_Template_From_Disk() { var fileName = System.IO.Path.GetTempFileName(); try { // Given string expected; using (var ms = new MemoryStream()) using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Reporting.Generic.Tests.Templates.TestTemplate.cshtml")) { if (stream == null) { throw new ApplicationException("Resource 'Cake.Issues.Reporting.Generic.Tests.Templates.TestTemplate.cshtml' not found."); } stream.CopyTo(ms); var data = ms.ToArray(); using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { file.Write(data, 0, data.Length); } expected = ConvertFromUtf8(data); } // When var settings = GenericIssueReportFormatSettings.FromFilePath(fileName); // Then settings.Template.ShouldBe(expected); } finally { if (File.Exists(fileName)) { File.Delete(fileName); } } }