public void Check_TimeResolution_Hour_Should_Return_String_h() { var type = TimeResolution.HOUR; var name = EnumLookup.GetTimeResolutionName(type); Assert.Equal("h", name); }
public void Check_TimeResolution_Day_Should_Return_String_d() { var type = TimeResolution.DAY; var name = EnumLookup.GetTimeResolutionName(type); Assert.Equal("d", name); }
public void Check_TimeResolution_Month_Should_Return_String_m() { var type = TimeResolution.MONTH; var name = EnumLookup.GetTimeResolutionName(type); Assert.Equal("m", name); }
/// <summary> /// Returns the properties as a query string to be used in an HTTP request. /// /// Datetime fields start and end window ranges will be converted into unix epoch format. /// </summary> /// <exception cref="ArgumentOutOfRangeException">Starting Date cannot be after ending date for datetime range.</exception> /// <returns>string value as a http query string.</returns> public string ToQueryString() { var queryStringBuilder = new QueryStringBuilder(); if (!this.End.HasValue) { this.End = this.provider.Now(); } if (!this.Start.HasValue) { this.Start = this.provider.Now().Minus(NodaTime.Duration.FromDays(7)); } if (this.Start.Value.CompareTo(this.End.Value) > 0) { throw new ArgumentOutOfRangeException(nameof(this.Start), "The starting date range window cannot be after the ending date range."); } if (this.Duration.HasValue && this.Resolution.HasValue) { queryStringBuilder.Append("duration", $"{this.Duration.Value}{EnumLookup.GetTimeResolutionName(this.Resolution.Value)}"); } else { queryStringBuilder.Append("start", this.Start.Value.ToRfc2822DateFormat()) .Append("end", this.End.Value.ToRfc2822DateFormat()); } if (this.EventTypes != null && this.EventTypes.Count > 0) { foreach (var eventType in this.EventTypes) { queryStringBuilder.Append("event", EnumLookup.GetEventTypeName(eventType)); } } return(queryStringBuilder.ToString()); }