public async Task Update_ReturnsUpdatedCode() { string usersJson = File.ReadAllText(TestConfiguration.MockDataFolderPath + @"Users.json"); var user = JsonConvert.DeserializeObject <List <User> >(usersJson).First(u => u.Id == TESTING_USER_ID); const string newCode = "1232123"; DateTime newExpirationDate = DateTime.Now.AddMinutes(5); var newVerificationCode = new UserEmailVerificationCode { Id = 1, User = user, Code = newCode, ExpiredDate = newExpirationDate }; UserEmailVerificationCodeRepository .Setup(r => r.GetByUserId(TESTING_USER_ID)) .Returns(newVerificationCode); UserEmailVerificationCodeRepository .Setup(r => r.Update(newVerificationCode)) .ReturnsAsync(newVerificationCode); var resultToken = await UserEmailVerificationCodeService.Update(newVerificationCode); Assert.NotNull(resultToken); Assert.NotNull(resultToken.User); Assert.Equal(TESTING_USER_ID, resultToken.User.Id); Assert.Equal(newCode, resultToken.Code); Assert.Equal(newExpirationDate, resultToken.ExpiredDate); }
public UserEmailVerificationCodeServiceTest() { UserEmailVerificationCodeRepository = new Mock <IUserEmailVerificationCodeRepository>(); ContextProvider = new Mock <IContextProvider>(); ContextProvider .Setup(c => c.GetRepository <IUserEmailVerificationCodeRepository>()) .Returns(UserEmailVerificationCodeRepository.Object); UserEmailVerificationCodeService = new UserEmailVerificationCodeService(ContextProvider.Object); }