Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmihai committed Aug 28, 2021
1 parent 414393f commit a636391
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Build.UnitTests/BackEnd/DebugUtils_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.IO;
using System.Linq;
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;

namespace Microsoft.Build.UnitTests
{
public class DebugUtils_Tests
{
[Fact]
public void DumpExceptionToFileShouldWriteInTempPathByDefault()
{
Directory.GetFiles(Path.GetTempPath(), "MSBuild_*failure.txt").ShouldBeEmpty();

string[] exceptionFiles = null;

try
{
ExceptionHandling.DumpExceptionToFile(new Exception("hello world"));
exceptionFiles = Directory.GetFiles(Path.GetTempPath(), "MSBuild_*failure.txt");
}
finally
{
exceptionFiles.ShouldNotBeNull();
exceptionFiles.ShouldHaveSingleItem();

var exceptionFile = exceptionFiles.First();
File.ReadAllText(exceptionFile).ShouldContain("hello world");
File.Delete(exceptionFile);
}
}
}
}

0 comments on commit a636391

Please sign in to comment.