public async Task IsUserSignedInAsync_NoSignedInUserSavedExpiredAndRefreshSucceeds_ReturnsTrue() { //Arrange var sut = CreateSut(); var email = "*****@*****.**"; var id = Guid.NewGuid(); var role = "role"; var refresh = Guid.NewGuid().ToString(); SubscribeAuthChanged(sut); _mocker.GetMock <ITokenManager>().Setup(o => o.GetTokenAsync()) .ReturnsAsync(JwtHelper.CreateFakeToken(id, email, role, DateTime.Now.AddHours(-1), refresh)); _mocker.GetMock <IAuthenticationProxy>() .Setup(o => o.RefreshAsync(refresh, email)) .ReturnsAsync(JwtHelper.CreateFakeToken(id, email, role, DateTime.Now.AddHours(-1))); //Act var result = await sut.IsUserSignedInAsync(); //Assert result.ShouldBeTrue(); sut.User.ShouldNotBeNull(); sut.EmailAddress.ShouldBe(email); sut.Id.ShouldBe(id); sut.Role.ShouldBe(role); }
public async Task IsUserSignedInAsync_NoSignedInUserSavedExpiredAndRefreshFails_ReturnsFalse() { //Arrange var sut = CreateSut(); SubscribeAuthChanged(sut); _mocker.GetMock <ITokenManager>().Setup(o => o.GetTokenAsync()) .ReturnsAsync(JwtHelper.CreateFakeToken(Guid.NewGuid(), "", "", DateTime.Now.AddHours(-1))); //Act var result = await sut.IsUserSignedInAsync(); //Assert result.ShouldBeFalse(); _user.ShouldBeNull(); }