public void Should_Throw_If_LogFileContent_Is_Null() { // Given / When var result = Record.Exception(() => InspectCodeIssuesSettings.FromContent(null)); // Then result.IsArgumentNullException("logFileContent"); }
public void Should_Throw_If_LogFileContent_Is_WhiteSpace() { // Given / When var result = Record.Exception(() => InspectCodeIssuesSettings.FromContent(" ")); // Then result.IsArgumentOutOfRangeException("logFileContent"); }
public void Should_Set_Property_Values_Passed_To_Constructor() { // Given const string logFileContent = "foo"; // When var settings = InspectCodeIssuesSettings.FromContent(logFileContent); // Then settings.LogFileContent.ShouldBe(logFileContent); }
public void Should_Throw_If_Log_Is_Null() { // Given / When var result = Record.Exception(() => new InspectCodeIssuesProvider( null, InspectCodeIssuesSettings.FromContent(@"foo"))); // Then result.IsArgumentNullException("log"); }
public void Should_Set_LogFileContent_If_Empty() { // Given byte[] logFileContent = Array.Empty <byte>(); // When var settings = new InspectCodeIssuesSettings(logFileContent); // Then settings.LogFileContent.ShouldBe(logFileContent); }
public void Should_Set_LogFileContent() { // Given var logFileContent = "Foo".ToByteArray(); // When var settings = new InspectCodeIssuesSettings(logFileContent); // Then settings.LogFileContent.ShouldBe(logFileContent); }
public void Should_Set_LogFileContent_From_LogFilePath() { // Given using (var tempFile = new ResourceTempFile("Cake.Issues.InspectCode.Tests.Testfiles.inspectcode.xml")) { // When var settings = new InspectCodeIssuesSettings(tempFile.FileName); // Then settings.LogFileContent.ShouldBe(tempFile.Content); } }
public InspectCodeIssuesProviderFixture(string fileResourceName) { this.Log = new FakeLog { Verbosity = Verbosity.Normal }; using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.InspectCode.Tests.Testfiles." + fileResourceName)) { using (var sr = new StreamReader(stream)) { this.Settings = InspectCodeIssuesSettings.FromContent( sr.ReadToEnd()); } } this.PrcaSettings = new ReportIssuesToPullRequestSettings(@"c:\Source\Cake.Prca"); }
public void Should_Read_File_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.Prca.Issues.InspectCode.Tests.Testfiles.inspectcode.xml")) { stream.CopyTo(ms); var data = ms.ToArray(); using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { file.Write(data, 0, data.Length); } expected = Encoding.UTF8.GetString(data, 0, data.Length); } // When var settings = InspectCodeIssuesSettings.FromFilePath(new FilePath(fileName)); // Then settings.LogFileContent.ShouldBe(expected); } finally { if (File.Exists(fileName)) { File.Delete(fileName); } } }