public void Empty() { using (var context = new UnitTestContext(this)) { var empty = new LocalDate(); context.Log.Assert(empty == LocalDateUtil.Empty, "empty == LocalDateUtil.Empty"); context.Log.Assert(empty.HasValue() == false, "empty.HasValue() == false"); context.Log.Assert(empty.ToIsoString() == String.Empty, "empty.ToIsoString() == String.Empty"); context.Log.Assert(empty.AsString() == String.Empty, "empty.AsString() == String.Empty"); } }
/// <summary> /// Verify that the result of serializing and then deserializing /// an object is the same as the original. /// </summary> private void VerifyRoundtrip(Context context, LocalDate value) { // Verify string serialization roundtrip string stringValue = value.AsString(); LocalDate parsedStringValue = LocalDateUtil.Parse(stringValue); Assert.Equal(value, parsedStringValue); context.Log.Verify($"ISO 8601 format: {stringValue}"); // Verify int serialization roundtrip int intValue = value.ToIsoInt(); LocalDate parsedIntValue = LocalDateUtil.FromIsoInt(intValue); Assert.Equal(value, parsedIntValue); context.Log.Verify($"Readable int format: {intValue}"); }
private void SetImageUrls() { var politicianKey = LabelPoliticianKey.Text.Trim(); var latestLogInfo = LogDataChange.GetTwoLatestProfileImageInfos(politicianKey); var date = latestLogInfo.Count < 1 ? PoliticiansImagesData.GetProfileOriginalDate(politicianKey, DefaultDbDate) : latestLogInfo[0].DateStamp; var dateTag = LocalDate.AsString(date, "M/D/YYYY h:mm:ss A"); ProfileImageHeading.InnerHtml = latestLogInfo.Count < 1 ? $"Newly-Uploaded Profile:<br />{dateTag}" : $"Newly-Uploaded Profile<br />({dateTag} by {latestLogInfo[0].UserName}):"; byte[] loggedBlob = null; if (latestLogInfo.Count >= 2) { loggedBlob = LatestLoggedImagePage.GetLoggedImageByDate(politicianKey, new DateTime(latestLogInfo[1].DateStamp.Ticks)); } //if (latestLogInfo.Count < 2) if (loggedBlob == null) { LoggedImage.Visible = false; LoggedImageSize.Visible = false; LoggedImageHeading.InnerHtml = "No logged profile available"; LoggedImageHeading.Style.Add(HtmlTextWriterStyle.Color, "red"); ButtonRevertToLog.Visible = false; } else { LoggedImage.Visible = true; LoggedImageSize.Visible = true; LoggedImageHeading.InnerHtml = $"Most Recent Logged Profile<br/>({LocalDate.AsString(latestLogInfo[1].DateStamp, "M/D/YYYY h:mm:ss A")}" + $" by {latestLogInfo[1].UserName}):"; LoggedImageHeading.Style.Add(HtmlTextWriterStyle.Color, "black"); ButtonRevertToLog.Visible = true; LoggedImage.ImageUrl = "/master/latestloggedimage.aspx?id=" + politicianKey + "&ticks=" + latestLogInfo[1].DateStamp.Ticks; //var loggedBlob = // LatestLoggedImagePage.GetLoggedImageByDate(politicianKey, // new DateTime(latestLogInfo[1].DateStamp.Ticks)); var loggedImage = Image.FromStream(new MemoryStream(loggedBlob)); LoggedImageSize.InnerHtml = $"{loggedImage.Width}x{loggedImage.Height}"; } OriginalImage.ImageUrl = InsertNoCacheIntoUrl(Url_Image_Politician_Original(politicianKey) + "&Def=1"); var blob = ImageManager.GetPoliticianImage(politicianKey, "ProfileOriginal", "ProfileOriginal", true); var image = Image.FromStream(new MemoryStream(blob)); OriginalImageSize.InnerHtml = $"{image.Width}x{image.Height}"; Image15.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize15Headshot) + "&Def=1"); Image20.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize20Headshot) + "&Def=1"); Image25.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize25Headshot) + "&Def=1"); Image35.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize35Headshot) + "&Def=1"); Image50.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize50Headshot) + "&Def=1"); Image75.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize75Headshot) + "&Def=1"); Image100.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize100Headshot) + "&Def=1"); Image200.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize200Profile) + "&Def=1"); Image300.ImageUrl = InsertNoCacheIntoUrl( Url_Image_Politician(politicianKey, ImageSize300Profile) + "&Def=1"); }