Skip to content

Commit

Permalink
Improved testability
Browse files Browse the repository at this point in the history
1) disabled requirement of signature
2) added runtime discovery of folder with archives

changes by this commit are already present in 13ef1c3
  • Loading branch information
KOLANICH committed May 17, 2015
1 parent dae13c7 commit b9d33ff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
32 changes: 24 additions & 8 deletions SharpCompress.Test/TestBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
Expand All @@ -10,13 +11,12 @@ namespace SharpCompress.Test
{
public class TestBase
{
protected const string TEST_BASE_PATH = @"Z:\Git\sharpcompress";
protected static readonly string TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
protected static readonly string ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
protected static readonly string MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
protected static readonly string SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
protected static readonly string SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");

protected static string TEST_BASE_PATH=null;
protected static string TEST_ARCHIVES_PATH;
protected static string ORIGINAL_FILES_PATH;
protected static string MISC_TEST_FILES_PATH;
protected static string SCRATCH_FILES_PATH;
protected static string SCRATCH2_FILES_PATH;
protected static IEnumerable<string> GetRarArchives()
{
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.none.rar");
Expand Down Expand Up @@ -152,10 +152,26 @@ protected void CompareArchivesByPath(string file1, string file2)

private static readonly object testLock = new object();

private TestContext ctx;
public TestContext TestContext {

This comment has been minimized.

Copy link
@norvegec

norvegec May 17, 2015

feel free to use auto properties here ( TestContext { get; set; } )

get {
return ctx;
}
set {
ctx = value;
}
}

[TestInitialize]
public void TestSetup()
{
Monitor.Enter(testLock);
TEST_BASE_PATH = Path.GetDirectoryName(Path.GetDirectoryName(ctx.TestDir));
TEST_ARCHIVES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Archives");
ORIGINAL_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Original");
MISC_TEST_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "MiscTest");
SCRATCH_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch");
SCRATCH2_FILES_PATH = Path.Combine(TEST_BASE_PATH, "TestArchives", "Scratch2");
}

[TestCleanup]
Expand Down
4 changes: 2 additions & 2 deletions SharpCompress/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
[assembly: AssemblyProduct("SharpCompress")]
[assembly:
InternalsVisibleTo(
"SharpCompress.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
"SharpCompress.Test"
)]
[assembly:
InternalsVisibleTo(
"SharpCompress.Test.Portable, PublicKey=002400000480000094000000060200000024000052534131000400000100010005d6ae1b0f6875393da83c920a5b9408f5191aaf4e8b3c2c476ad2a11f5041ecae84ce9298bc4c203637e2fd3a80ad5378a9fa8da1363e98cea45c73969198a4b64510927c910001491cebbadf597b22448ad103b0a4007e339faf8fe8665dcdb70d65b27ac05b1977c0655fad06b372b820ecbdccf10a0f214fee0986dfeded"
"SharpCompress.Test.Portable"
)]
#endif

Expand Down

1 comment on commit b9d33ff

@norvegec
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KOLANICH , maybe you can split it into 2 commits?
I vote for 1)
2) I agree with some test environment encapsulation. But should it be MsTest-only-dependencies(TestContext)? And [TestInitialize] is per test method rather than [ClassInitialize] or original static field initializers.

Please sign in to comment.