Permalink
Browse files

Cleanup tests

  • Loading branch information...
1 parent 0473781 commit e02135c79cced78f82549263b97901df0299abf9 @davidebbo committed Oct 27, 2011
@@ -14,6 +14,13 @@ public class ActivationManager
private static bool _hasInited;
private static List<Assembly> _assemblies;
+ // For unit test purpose
+ internal static void Reset()
+ {
+ _hasInited = false;
+ _assemblies = null;
+ }
+
public static void Run()
{
if (!_hasInited)
@@ -23,6 +23,8 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3bc078bd-ade4-4271-964f-1d041508c419")]
+[assembly: InternalsVisibleTo("WebActivatorTest")]
+
// Version information for an assembly consists of the following four values:
//
// Major Version
@@ -6,11 +6,19 @@ namespace WebActivatorTest
[TestClass]
public class WebActivatorUnitTest
{
+ [TestInitialize]
+ public void TestInit()
+ {
+ WebActivator.ActivationManager.Reset();
+ MyStartupCode.StartCalled = false;
+ MyStartupCode.Start2Called = false;
+ MyStartupCode.CallMeAfterAppStartCalled = false;
+ MyStartupCode.CallMeWhenAppEndsCalled = false;
+ }
+
[TestMethod]
public void TestWebActivatorAllStartMethodsGetCalled()
{
- MyStartupCode.StartCalled = MyStartupCode.Start2Called = MyStartupCode.CallMeAfterAppStartCalled = false;
-
WebActivator.ActivationManager.Run();
Assert.IsTrue(TestLibrary.MyStartupCode.StartCalled);
@@ -21,8 +29,6 @@ public void TestWebActivatorAllStartMethodsGetCalled()
[TestMethod]
public void TestWebActivatorPreStartMethodsGetCalled()
{
- MyStartupCode.StartCalled = MyStartupCode.Start2Called = MyStartupCode.CallMeAfterAppStartCalled = false;
-
WebActivator.ActivationManager.RunPreStartMethods();
Assert.IsTrue(TestLibrary.MyStartupCode.StartCalled);
@@ -33,8 +39,6 @@ public void TestWebActivatorPreStartMethodsGetCalled()
[TestMethod]
public void TestWebActivatorPostStartMethodsGetCalled()
{
- MyStartupCode.StartCalled = MyStartupCode.Start2Called = MyStartupCode.CallMeAfterAppStartCalled = false;
-
WebActivator.ActivationManager.RunPostStartMethods();
Assert.IsFalse(TestLibrary.MyStartupCode.StartCalled);
@@ -45,8 +49,6 @@ public void TestWebActivatorPostStartMethodsGetCalled()
[TestMethod]
public void TestWebActivatorShutdownMethodsGetCalled()
{
- MyStartupCode.CallMeWhenAppEndsCalled = false;
-
WebActivator.ActivationManager.RunShutdownMethods();
Assert.IsTrue(MyStartupCode.CallMeWhenAppEndsCalled);

0 comments on commit e02135c

Please sign in to comment.