Last active
July 2, 2020 09:50
-
-
Save Kralizek/64794cb747ef84131a7e33cad58852a5 to your computer and use it in GitHub Desktop.
Unit Testing in C#
This file contains hidden or 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
using System.Diagnostics; | |
using NUnit.Framework; | |
[SetUpFixture] | |
public class RootFixtureSetup | |
{ | |
[OneTimeSetUp] | |
public void OneTimeSetUp() => Debug.WriteLine("RootFixtureSetup:OneTimeSetUp"); | |
[OneTimeTearDown] | |
public void OneTimeTearDown() => Debug.WriteLine("RootFixtureSetup:OneTimeTearDown"); | |
} | |
namespace TestLifeCycle | |
{ | |
[SetUpFixture] | |
public class FixtureSetup | |
{ | |
[OneTimeSetUp] | |
public void OneTimeSetUp() => Debug.WriteLine("FixtureSetup:OneTimeSetUp"); | |
[OneTimeTearDown] | |
public void OneTimeTearDown() => Debug.WriteLine("FixtureSetup:OneTimeTearDown"); | |
} | |
[TestFixture] | |
public class Tests | |
{ | |
[OneTimeSetUp] | |
public void OneTimeSetUp() => Debug.WriteLine("Tests:OneTimeSetUp"); | |
[SetUp] | |
public void Setup() => Debug.WriteLine("Tests:SetUp"); | |
public Tests() => Debug.WriteLine("Tests:Constructor"); | |
[Test] | |
public void Test1() => Debug.WriteLine("Tests:Test1"); | |
[Test] | |
public void Test2() => Debug.WriteLine("Tests:Test2"); | |
[TearDown] | |
public void TearDown() => Debug.WriteLine("Tests:TearDown"); | |
[OneTimeTearDown] | |
public void OneTimeTearDown() => Debug.WriteLine("Tests:OneTimeTearDown"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment