Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Fixes for tests to succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 28, 2019
1 parent afa5711 commit d2654f5
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 208 deletions.
14 changes: 5 additions & 9 deletions OMODFramework.Test/ATest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ public abstract class ATest

public abstract HashSet<NexusFile> Files { get; set; }

public abstract bool DeleteOnFinish { get; set; }

[TestInitialize]
public void Setup()
{
Framework.TempDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestTempDir");

if (!Directory.Exists(Framework.TempDir))
Directory.CreateDirectory(Framework.TempDir);
else
Framework.CleanTempDir();

if (Files.All(f => File.Exists(f.DownloadFileName) && File.Exists(f.FileName)))
return;

Expand Down Expand Up @@ -81,12 +84,5 @@ public void Setup()
}
});
}

[TestCleanup]
public void Cleanup()
{
if(DeleteOnFinish)
Framework.CleanTempDir(true);
}
}
}
2 changes: 1 addition & 1 deletion OMODFramework.Test/OMODTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class OMODTests : ATest
}
};

public override bool DeleteOnFinish { get; set; } = true;
public virtual bool DeleteOnFinish { get; set; } = true;

[TestMethod]
public void TestOMOD()
Expand Down
2 changes: 1 addition & 1 deletion OMODFramework.Test/ScriptFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Version GraphicsExtenderVersion()

public Version OblivionVersion()
{
return new Version(1, 2, 0, 416);
return new Version(1, 2, 416, 0);
}
}
}
2 changes: 1 addition & 1 deletion OMODFramework.Test/ScriptTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class ScriptTest : ATest
}*/
};

public override bool DeleteOnFinish { get; set; } = false;
public virtual bool DeleteOnFinish { get; set; } = false;

[TestMethod]
public void TestOBMMScript()
Expand Down
16 changes: 15 additions & 1 deletion OMODFramework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ public static void CleanTempDir(bool deleteRoot = false)
return;

var dInfo = new DirectoryInfo(TempDir);
dInfo.GetFiles().Do(f => {if(f.Exists && !f.IsReadOnly) f.Delete();});
dInfo.GetFiles().Do(f =>
{
if (!f.Exists || f.IsReadOnly)
return;

try
{
f.Delete();
}
catch
{
// ignored
}

});
dInfo.GetDirectories().Do(d => {if(d.Exists && !d.Attributes.HasFlag(FileAttributes.ReadOnly)) d.Delete(true);});

if(deleteRoot)
Expand Down
Loading

0 comments on commit d2654f5

Please sign in to comment.