private static TokenSet CreateTestTokenSet(Instant testStartTime, string id, string orgKey, string userId = "UpdatedUserId") { const int UPDATED_EXPIRES_IN = 2; var testTokenSet = new TokenSet( "UpdatedAccessToken", "UpdatedTokenType", UPDATED_EXPIRES_IN, new Uri("https://uri/updated"), orgKey, "UpdatedRefreshToken", testStartTime.PlusTicks(1000), userId, id, new JwtSecurityToken("UpdatedIssuer", "UpdatedAudience") ); return(testTokenSet); }
/// <summary> /// Initializes a new instance of the <see cref="SchemaExamples"/> class. /// Creates example value by provided <see cref="DateTime"/> and <see cref="IDateTimeZoneProvider"/>. /// </summary> /// <param name="dateTimeZoneProvider">IDateTimeZoneProvider instance.</param> /// <param name="dateTimeUtc"><see cref="DateTime"/>. If not set then <see cref="DateTime.UtcNow"/> will be used.</param> /// <param name="dateTimeZone">Optional DateTimeZone name. If not set SystemDefault will be used.</param> public SchemaExamples( IDateTimeZoneProvider dateTimeZoneProvider, DateTime?dateTimeUtc = null, string?dateTimeZone = null) { DateTime dateTimeUtcValue = dateTimeUtc ?? DateTime.UtcNow; if (dateTimeUtcValue.Kind != DateTimeKind.Utc) { throw new ArgumentException("dateTimeUtc should be UTC", nameof(dateTimeUtc)); } if (dateTimeZone != null) { DateTimeZone = dateTimeZoneProvider.GetZoneOrNull(dateTimeZone) ?? dateTimeZoneProvider.GetSystemDefault(); } else { DateTimeZone = dateTimeZoneProvider.GetSystemDefault(); } Instant = Instant.FromDateTimeUtc(dateTimeUtcValue); ZonedDateTime = Instant.InZone(DateTimeZone); Interval = new Interval(Instant, Instant.PlusTicks(TimeSpan.TicksPerDay) .PlusTicks(TimeSpan.TicksPerHour) .PlusTicks(TimeSpan.TicksPerMinute) .PlusTicks(TimeSpan.TicksPerSecond) .PlusTicks(TimeSpan.TicksPerMillisecond)); DateInterval = new DateInterval(ZonedDateTime.Date, ZonedDateTime.Date.PlusDays(1)); Period = Period.Between(ZonedDateTime.LocalDateTime, Interval.End.InZone(DateTimeZone).LocalDateTime, PeriodUnits.AllUnits); OffsetDate = new OffsetDate(ZonedDateTime.Date, ZonedDateTime.Offset); OffsetTime = new OffsetTime(ZonedDateTime.TimeOfDay, ZonedDateTime.Offset); OffsetDateTime = Instant.WithOffset(ZonedDateTime.Offset); }
public NodaValue() { try { DateTimeZone = DateTimeZoneProviders.Tzdb.GetSystemDefault(); } catch (DateTimeZoneNotFoundException) { DateTimeZone = DateTimeZoneProviders.Tzdb["America/New_York"]; } Instant = Instant.FromDateTimeUtc(DateTime.UtcNow); ZonedDateTime = Instant.InZone(DateTimeZone); OffsetDateTime = Instant.WithOffset(ZonedDateTime.Offset); Interval = new Interval(Instant, Instant .PlusTicks(TimeSpan.TicksPerDay) .PlusTicks(TimeSpan.TicksPerHour) .PlusTicks(TimeSpan.TicksPerMinute) .PlusTicks(TimeSpan.TicksPerSecond) .PlusTicks(TimeSpan.TicksPerMillisecond)); Period = Period.Between(LocalDateTime, Interval.End.InZone(DateTimeZone).LocalDateTime, PeriodUnits.AllUnits); }
private static ActionstepCredential CreateTestCredential(Instant testStartTime, bool withLock) { return(new ActionstepCredential() { AccessToken = "AccessToken", AccessTokenExpiryUtc = testStartTime.PlusTicks(100).ToDateTimeUtc(), ActionstepOrg = new ActionstepOrg() { Key = "ActionstepOrg" }, ApiEndpoint = new Uri("https://uri/"), CreatedBy = new WCAUser() { Email = "CreatedBy@Domain" }, DateCreatedUtc = testStartTime.PlusTicks(200).ToDateTimeUtc(), ExpiresIn = 1, Id = 2, IdToken = new JwtSecurityToken("Issuer", "Audience"), LastUpdatedUtc = testStartTime.PlusTicks(300).ToDateTimeUtc(), LockExpiresAtUtc = withLock ? testStartTime.PlusTicks(400).ToDateTimeUtc() : default(DateTime), LockId = withLock ? new Guid("11111111-1111-1111-1111-111111111111") : Guid.Empty, Owner = new WCAUser() { Id = "UserId", Email = "Owner@Domain" }, ReceivedAtUtc = testStartTime.PlusTicks(500).ToDateTimeUtc(), RefreshToken = "RefreshToken", RefreshTokenExpiryUtc = testStartTime.PlusTicks(600).ToDateTimeUtc(), TokenType = "TokenType", UpdatedBy = new WCAUser() { Email = "UpdatedBy@Domain" }, RevokedAtUtc = testStartTime.PlusTicks(700).ToDateTimeUtc() }); }
public void PlusTicks() { Instant instant = Instant.FromUnixTimeTicks(5); Assert.AreEqual(Instant.FromUnixTimeTicks(8), instant.PlusTicks(3)); }
public void PlusTicks() { Instant instant = new Instant(5); Assert.AreEqual(new Instant(8), instant.PlusTicks(3)); }
public static Instant InstantFromFileTimeUtc(long fileTimeTicks) { return(FileTimeEpoch.PlusTicks(fileTimeTicks)); }
public void PlusTicks() { Instant instant = Instant.FromTicksSinceUnixEpoch(5); Assert.AreEqual(Instant.FromTicksSinceUnixEpoch(8), instant.PlusTicks(3)); }