public void GetIdByMail_GiveIncorrectMail_ThrowException() { var users = new List <UserTO> { new UserTO { Company = "EvilCorp", Email = "*****@*****.**", Id = 3, IsArchived = false, Name = "Marcel", Role = UserRole.Attendee, }, new UserTO { Company = "GoodCorp", Email = "*****@*****.**", Id = 4, IsArchived = false, Name = "Jean-Louis", Role = UserRole.Attendee, }, new UserTO { Company = "BofCorp", Email = "*****@*****.**", Id = 2, IsArchived = false, Name = "Clara", Role = UserRole.Attendee, } }; var mockUnitOfWork = new Mock <IRSUnitOfWork>(); mockUnitOfWork.Setup(u => u.UserRepository.GetAll()).Returns(users); var sut = new RSAttendeeRole(mockUnitOfWork.Object); //ASSERT Assert.ThrowsException <LoggedException>(() => sut.GetIdByMail("*****@*****.**")); Assert.ThrowsException <LoggedException>(() => sut.GetIdByMail(" ")); Assert.ThrowsException <LoggedException>(() => sut.GetIdByMail(null)); }
public void GetIdByMail_Successful() { var users = new List <UserTO> { new UserTO { Company = "CaBossDur", Email = "*****@*****.**", Id = 3, IsArchived = false, Name = "Marcel", Role = UserRole.Attendee, }, new UserTO { Company = "CaBossDur2", Email = "*****@*****.**", Id = 4, IsArchived = false, Name = "Jean-Louis", Role = UserRole.Attendee, }, new UserTO { Company = "CaBossDur3", Email = "*****@*****.**", Id = 2, IsArchived = false, Name = "Clara", Role = UserRole.Attendee, } }; var mockUnitOfWork = new Mock <IRSUnitOfWork>(); mockUnitOfWork.Setup(u => u.UserRepository.GetAll()).Returns(users); var sut = new RSAttendeeRole(mockUnitOfWork.Object); //ACT var result = sut.GetIdByMail("*****@*****.**"); //ASSERT mockUnitOfWork.Verify(u => u.UserRepository.GetAll(), Times.Once); Assert.AreEqual(3, result); }