Files
AndroidDeviceStreaming/desktop/Ads.Desktop.Tests/DailyLogTests.cs
T

18 lines
805 B
C#

using Ads.Desktop;
using Xunit;
namespace Ads.Desktop.Tests;
public class DailyLogTests {
[Fact] public void PersistsAndCleansOnlyOwnedExpiredLogs() {
var folder=Path.Combine(Path.GetTempPath(),Guid.NewGuid().ToString());
Directory.CreateDirectory(folder);
try {
File.WriteAllText(Path.Combine(folder,"ads-2000-01-01.1.log"),"old");
File.WriteAllText(Path.Combine(folder,"ads-2000-01-01-custom.log"),"keep");
new DailyLog(folder).Write("connection diagnostic");
Assert.False(File.Exists(Path.Combine(folder,"ads-2000-01-01.1.log")));
Assert.True(File.Exists(Path.Combine(folder,"ads-2000-01-01-custom.log")));
Assert.Contains("connection diagnostic",File.ReadAllText(Path.Combine(folder,$"ads-{DateTime.Now:yyyy-MM-dd}.log")));
} finally { Directory.Delete(folder,true); }
}
}