Guest User

Untitled

a guest
Apr 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. namespace MyNamespace
  2. {
  3. [SetUpFixture]
  4. public class MySetUpClass
  5. {
  6. [SetUp]
  7. public void GlobalInit()
  8. {
  9. //Code placed here is going to be executed once per group of fixtures (group of fixtures = fixtures in the same namespace).
  10. }
  11.  
  12. [TearDown]
  13. public void GlobalDispose()
  14. {
  15. //Code placed here is going to be executed once per group of fixtures (group of fixtures = fixtures in the same namespace).
  16. }
  17. }
  18.  
  19. [TestFixture]
  20. public class UserTests
  21. {
  22. [TestFixtureSetUp]
  23. public void GeneralInit()
  24. {
  25. //Code placed here is going to be executed once per fixture.
  26. }
  27.  
  28. [TestFixtureTearDown]
  29. public void GeneralDispose()
  30. {
  31. //Code placed here is going to be executed once per fixture.
  32. }
  33.  
  34. [SetUp]
  35. public void Init()
  36. {
  37. //Code placed here going to be executed once per test.
  38. }
  39.  
  40. [TearDown]
  41. public void Dispose()
  42. {
  43. //Code placed here going to be executed once per test.
  44. }
  45.  
  46. [Test]
  47. public void Authenticate_WithoutPassword_ReturnsFailedState()
  48. {
  49. //Arrange
  50. var queryableExpectedResult = Enumerable.Empty<UserDTO>().AsQueryable();
  51. var userRepositoryStub = new Mock<IUserRepository>();
  52. userRepositoryStub.Setup(x => x.GetUsersByUsernameAndPassword(It.IsAny<string>(), It.IsAny<string>()))
  53. .Returns(queryableExpectedResult);
  54.  
  55. var userService = new UserService(userRepositoryStub.Object) { Username = "admin2", Password = "" };
  56. //Act, Assert
  57. Assert.IsFalse(userService.Authenticate());
  58. }
  59. }
  60. }
Add Comment
Please, Sign In to add comment