public AccessToken(string value, string?refreshToken, ITimeToLive timeToLive) { if (string.IsNullOrWhiteSpace(value)) { throw Errors.StringShouldNotBeNullOrWhiteSpace(nameof(value)); } if (refreshToken != null && string.IsNullOrWhiteSpace(refreshToken)) { throw Errors.StringShouldNotBeEmptyOrWhiteSpace(nameof(refreshToken)); } if (ReferenceEquals(timeToLive, null)) { throw new ArgumentNullException(nameof(timeToLive)); } if (timeToLive.HasExpired) { throw Errors.AccessTokenAlreadyExpired(nameof(timeToLive)); } this.value = value; this.refreshToken = refreshToken; this.timeToLive = timeToLive; }
private static void ShouldFail(string accessToken, string refreshToken, ITimeToLive timeToLive) { Action action = () => _ = new AccessToken(accessToken, refreshToken, timeToLive); action.Should().Throw <ArgumentException>(); }