Created
June 29, 2014 15:11
-
-
Save scottlaw1/a1b5dc5f058a0b02a95c to your computer and use it in GitHub Desktop.
Example of abstract class I use for unit testing with XUnit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class UnitTestBase : IUseFixture<UnitTestFixture>{ | |
public void SetFixture(UnitTestFixture data){ | |
Fixture = data; | |
AdditionalFixtureConfiguration(); | |
} | |
protected UnitTestFixture Fixture {get;set;} | |
public virtual void AdditionalFixtureConfiguration(){ | |
} | |
} | |
public class UnitTestFixture : IDisposable{ | |
public override void Dispose(){ | |
base.Dispose(); | |
Dispose(true); | |
GC.SuppressFinalize(this); | |
} | |
protected virtual void Dispose(bool disposing){ | |
if (!disposing)return; | |
//Free other managed objects here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment