Created
March 6, 2015 00:11
-
-
Save derekgreer/3cad52555a2f7351d3f6 to your computer and use it in GitHub Desktop.
My NUnit Test
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 class UserServiceSpecs | |
{ | |
[Subcutaneous] | |
public class when_creating_an_inactive_account : SubjectBuilderContext | |
{ | |
const string UserName = "testuser"; | |
static AccountInfo _accountInfo; | |
static ExpectedObject _expectedUser; | |
static IUserService _userService; | |
Cleanup after = () => DnxDatabase.DeleteUser(UserName); | |
Establish context = () => | |
{ | |
_userService = BuildSubject<IUserService>() | |
.WithContext<UserServiceContext>() | |
.WithMock<IIdentityMessageService>() | |
.Build(); | |
_accountInfo = new AccountInfo | |
{ | |
Email = "[email protected]", | |
Roles = new[] {"admin", "user"}, | |
UserName = UserName | |
}; | |
_expectedUser = new | |
{ | |
UserName, | |
IsActive = false, | |
PasswordHash = Expect.Null(), | |
Email = "[email protected]" | |
}.ToExpectedObject(); | |
}; | |
Because of = () => _userService.CreateAccount(_accountInfo); | |
It should_create_expected_account = () => _expectedUser.ShouldMatch(DnxDatabase.GetUserByUserName(UserName)); | |
It should_send_the_activation_email_to_the_user = () => For<IIdentityMessageService>().Verify(x => x.SendAsync(Moq.It.IsAny<IdentityMessage>()), Times.Once()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wait.... wahhhh?? How?