Skip to content

Commit

Permalink
Fix v4.0 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Einar Egilsson committed Jan 22, 2012
1 parent 5e91159 commit 214fa49
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions InjectModuleInitializer.csproj
Expand Up @@ -120,6 +120,7 @@
<ItemGroup>
<None Include="Test\Data\test.build">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<None Include="Test\Data\testkey.snk">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
2 changes: 1 addition & 1 deletion Test/Data/test.cs
Expand Up @@ -39,7 +39,7 @@ public class SomeOtherClass
{
public static void SomeOtherMethod()
{
System.Console.Write("<ModuleInit>");
System.Console.Write("<ExplicitModuleInit>");
}
}
}
2 changes: 1 addition & 1 deletion Test/TestRunner.cs
Expand Up @@ -44,7 +44,7 @@ public static int RunTests()
Console.Write(" "+ method.Name);
try
{
method.Invoke(new InjectModuleInitializerTest(), new object[0]);
method.Invoke(Activator.CreateInstance(t), new object[0]);
WriteColored("\r " + method.Name, ConsoleColor.Green);
success++;
}
Expand Down
37 changes: 21 additions & 16 deletions Test/UnitTests.cs
Expand Up @@ -156,21 +156,19 @@ public void ExeImplicitInitializer()
get { return "2.0.50727"; }
}

// [Test]
// public void TestExeImplicitInitializer()
// {
// TestExe(@"
// class Program {
// static void Main(){ System.Console.Write(""<MainMethod>""); }
// }
//
// namespace Foo.Bar {
// class ModuleInitializer {
// public static void Run() {System.Console.Write(""<ModuleInitializer>"");}
// }
// }
// ", null);
// }
[Test]
public void ExeExplicitInitializer()
{
var result = Build("ExeExplicitInitializer");
Assert.AreEqual(0, result.Result);
new Injector().Inject(@"Test\Data\ExeExplicitInitializer.exe","NS.SomeOtherClass::SomeOtherMethod", @"Test\Data\testkey.snk");
ExecResult execResult = Exec(@"Test\Data\ExeExplicitInitializer.exe", "");
Assert.AreEqual(0, execResult.Result);
Assert.IsTrue(execResult.StdOut.Contains("<ExplicitModuleInit><Main>"));
Assert.IsTrue(execResult.StdOut.Contains("ClrVersion: " + RuntimeVersion));
Assert.IsTrue(execResult.StdOut.Contains("AssemblyRuntime: v" + RuntimeVersion));
Assert.IsTrue(execResult.StdOut.Contains("PublicKey: 6dd84ac5c69bf74"));
}

// [Test]
// public void TestDllSuccess()
Expand Down Expand Up @@ -226,7 +224,10 @@ private ExecResult Exec(string program, string args)

private ExecResult Build(string outputName, string codefile="test.cs")
{
return Exec(MSBuild, string.Format(@"/p:AssemblyName={0};CodeFile={1} Test\Data\test.build", outputName, codefile));
if (File.Exists(outputName)) {
File.Delete(outputName);
}
return Exec(MSBuild, string.Format(@"/p:AssemblyName={0};CodeFile={1} /target:Clean;Build Test\Data\test.build", outputName, codefile));
}

}
Expand All @@ -237,6 +238,10 @@ protected override string MSBuild
{
get { return @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"; }
}
protected override string RuntimeVersion
{
get { return "4.0.30319"; }
}
}

}
Expand Down

0 comments on commit 214fa49

Please sign in to comment.