mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-06 02:56:32 +01:00
75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using TINK.Model.Logging;
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests
|
|
{
|
|
[TestFixture]
|
|
public class TestLoggingDirectoryManager
|
|
{
|
|
[Test]
|
|
public void TestConstructInvalidArgs()
|
|
{
|
|
Assert.Throws<ArgumentException>(
|
|
() => new LoggingDirectoryManager(
|
|
(name) => new List<string> { "2018_02_06_22_18_00" /* oldest */, "2018_02_06_23_10_00" /*youngest*/ , "2018_02_06_22_19_00", "2018_02_06_22_20_00" },
|
|
(name) => false,
|
|
(name) => { },
|
|
(name) => { },
|
|
"abc",
|
|
'\\',
|
|
0));
|
|
|
|
Assert.Throws<ArgumentException>(
|
|
() => new LoggingDirectoryManager(
|
|
(name) => new List<string> { "2018_02_06_22_18_00" /* oldest */, "2018_02_06_23_10_00" /*youngest*/ , "2018_02_06_22_19_00", "20180206222000" },
|
|
(name) => false,
|
|
(name) => { },
|
|
(name) => { },
|
|
"",
|
|
'\\',
|
|
3));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDeleteObsoleteLogs()
|
|
{
|
|
var l_oDeletedFilesList = new List<string>();
|
|
|
|
var l_oManger = new LoggingDirectoryManager(
|
|
(name) => new List<string> { "2018_02_06_22_18_00" /* oldest */, "2018_02_06_23_10_00" /*youngest*/ , "2018_02_06_22_19_00", "20180206222000" },
|
|
(name) => false,
|
|
(name) => { },
|
|
(name) => { l_oDeletedFilesList.Add(name); },
|
|
"abc",
|
|
'\\',
|
|
3);
|
|
|
|
l_oManger.DeleteObsoleteLogs();
|
|
|
|
Assert.AreEqual(2, l_oDeletedFilesList.Count);
|
|
Assert.IsTrue(l_oDeletedFilesList.Contains("2018_02_06_22_18_00"));
|
|
Assert.IsTrue(l_oDeletedFilesList.Contains("2018_02_06_22_19_00"));
|
|
}
|
|
|
|
[Test]
|
|
public void TestDeleteObsoleteLogs_EmptyDirectory()
|
|
{
|
|
var l_oDeletedFilesList = new List<string>();
|
|
|
|
var l_oManger = new LoggingDirectoryManager(
|
|
(name) => new List<string>(),
|
|
(name) => false,
|
|
(name) => { },
|
|
(name) => { l_oDeletedFilesList.Add(name); },
|
|
"abc",
|
|
'\\',
|
|
3);
|
|
|
|
l_oManger.DeleteObsoleteLogs();
|
|
|
|
Assert.AreEqual(0, l_oDeletedFilesList.Count);
|
|
}
|
|
}
|
|
}
|