Created
November 12, 2015 14:40
-
-
Save margusmartsepp/bf64cd645fe80e017765 to your computer and use it in GitHub Desktop.
fluent nunit tests
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
| [TestFixture] | |
| public class RepresentativeServiceTests | |
| { | |
| public class TestStory | |
| { | |
| public class Fail | |
| { | |
| public static IEnumerable Constructor | |
| { | |
| get | |
| { | |
| IUserContext userContext = null; | |
| INavServiceClient navServiceClient = null; | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context is null"); | |
| userContext = Mock.Of<IUserContext>(); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Service is null"); | |
| navServiceClient = Mock.Of<INavServiceClient>(); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.CustomerNumber is null"); | |
| Mock.Get(userContext).Setup(o => o.CustomerNumber).Returns((string)null); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.CustomerNumber has value (string)null"); | |
| Mock.Get(userContext).Setup(o => o.CustomerNumber).Returns(string.Empty); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.CustomerNumber has value string.Empty"); | |
| Mock.Get(userContext).Setup(o => o.CustomerNumber).Returns("000007"); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.PersonalCode is null"); | |
| Mock.Get(userContext).Setup(o => o.PersonalCode).Returns((string)null); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.PersonalCode has value (string)null"); | |
| Mock.Get(userContext).Setup(o => o.PersonalCode).Returns(string.Empty); | |
| yield return new TestCaseData(userContext, navServiceClient).Throws(typeof(ArgumentNullException)).SetName("Context.PersonalCode has value string.Empty"); | |
| } | |
| } | |
| } | |
| public class Pass | |
| { | |
| public static IEnumerable Constructor | |
| { | |
| get | |
| { | |
| var userContext = Mock.Of<IUserContext>(); | |
| var navServiceClient = Mock.Of<INavServiceClient>(); | |
| Mock.Get(userContext).Setup(o => o.CustomerNumber).Returns("000007"); | |
| Mock.Get(userContext).Setup(o => o.PersonalCode).Returns("38703070123"); | |
| yield return new TestCaseData(userContext, navServiceClient).SetName("Representative service created"); | |
| } | |
| } | |
| } | |
| } | |
| [Test, TestCaseSource(typeof(TestStory.Fail), nameof(TestStory.Fail.Constructor))] | |
| public void RepresentativeServiceFailTests(IUserContext userContext, INavServiceClient navServiceClient) | |
| { | |
| new RepresentativeService(userContext, navServiceClient); | |
| } | |
| [Test, TestCaseSource(typeof(TestStory.Pass), nameof(TestStory.Pass.Constructor))] | |
| public void RepresentativeServicePassTests(IUserContext userContext, INavServiceClient navServiceClient) | |
| { | |
| new RepresentativeService(userContext, navServiceClient); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment