public void ShowThumbnailAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new Dictionary <string, string> { { "http://foo.example.com/abcd", "http://foo.example.com/abcd" }, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(0)); Assert.That(thumbbox.scrollBar.Enabled, Is.False); Assert.That(thumbbox.pictureBox.Count, Is.EqualTo(1)); Assert.That(thumbbox.pictureBox[0].ImageLocation, Is.EqualTo("dot.gif")); var thumbinfo = thumbbox.pictureBox[0].Tag as ThumbnailInfo; Assert.That(thumbinfo, Is.Not.Null); Assert.That(thumbinfo.ImageUrl, Is.EqualTo("http://foo.example.com/abcd")); Assert.That(thumbinfo.ThumbnailUrl, Is.EqualTo("dot.gif")); Assert.That(thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0]), Is.EqualTo("")); } }
public async Task ShowThumbnailAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(0, thumbbox.scrollBar.Maximum); Assert.False(thumbbox.scrollBar.Enabled); Assert.Equal(1, thumbbox.pictureBox.Count); Assert.NotNull(thumbbox.pictureBox[0].Image); Assert.IsAssignableFrom <ThumbnailInfo>(thumbbox.pictureBox[0].Tag); var thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[0].Tag; Assert.Equal("http://foo.example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("http://img.example.com/abcd.png", thumbinfo.ThumbnailUrl); Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0])); } }
public void SetThumbnailCountTest(int count) { using (var thumbbox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("SetThumbnailCount", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(thumbbox, new[] { (object)count }); Assert.Equal(count, thumbbox.pictureBox.Count); var num = 0; foreach (var picbox in thumbbox.pictureBox) { Assert.Equal("pictureBox" + num, picbox.Name); num++; } Assert.Equal(thumbbox.pictureBox, thumbbox.panelPictureBox.Controls.Cast <OTPictureBox>()); Assert.Equal(0, thumbbox.scrollBar.Minimum); if (count == 0) { Assert.Equal(0, thumbbox.scrollBar.Maximum); } else { Assert.Equal(count - 1, thumbbox.scrollBar.Maximum); } } }
public void CancelAsyncTest() { using (var thumbbox = new TweetThumbnail()) { var post = new PostClass(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var task = thumbbox.ShowThumbnailAsync(post); thumbbox.CancelAsync(); Assert.That(task.IsCanceled, Is.True); } }
public void CancelAsyncTest() { using (var thumbbox = new TweetThumbnail()) { var post = new PostClass(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var task = thumbbox.ShowThumbnailAsync(post); thumbbox.CancelAsync(); Assert.Throws<AggregateException>(() => task.Wait()); Assert.True(task.IsCanceled); } }
public void CancelAsyncTest() { using (var thumbbox = new TweetThumbnail()) { var post = new PostClass(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var task = thumbbox.ShowThumbnailAsync(post); thumbbox.CancelAsync(); Assert.Throws <AggregateException>(() => task.Wait()); Assert.That(task.IsCanceled, Is.True); } }
public void CreatePictureBoxTest() { using (var thumbBox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("CreatePictureBox", BindingFlags.Instance | BindingFlags.NonPublic); var picbox = method.Invoke(thumbBox, new[] { "pictureBox1" }) as PictureBox; Assert.That(picbox, Is.Not.Null); Assert.That(picbox.Name, Is.EqualTo("pictureBox1")); Assert.That(picbox.SizeMode, Is.EqualTo(PictureBoxSizeMode.Zoom)); Assert.That(picbox.WaitOnLoad, Is.False); Assert.That(picbox.Dock, Is.EqualTo(DockStyle.Fill)); picbox.Dispose(); } }
public void CreatePictureBoxTest() { using (var thumbBox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("CreatePictureBox", BindingFlags.Instance | BindingFlags.NonPublic); var picbox = method.Invoke(thumbBox, new[] { "pictureBox1" }) as PictureBox; Assert.NotNull(picbox); Assert.Equal("pictureBox1", picbox !.Name); Assert.Equal(PictureBoxSizeMode.Zoom, picbox.SizeMode); Assert.False(picbox.WaitOnLoad); Assert.Equal(DockStyle.Fill, picbox.Dock); picbox.Dispose(); } }
public void CreatePictureBoxTest() { using (var thumbBox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("CreatePictureBox", BindingFlags.Instance | BindingFlags.NonPublic); var picbox = method.Invoke(thumbBox, new[] { "pictureBox1" }) as PictureBox; Assert.NotNull(picbox); Assert.Equal("pictureBox1", picbox.Name); Assert.Equal(PictureBoxSizeMode.Zoom, picbox.SizeMode); Assert.False(picbox.WaitOnLoad); Assert.Equal(DockStyle.Fill, picbox.Dock); picbox.Dispose(); } }
public async Task ScrollTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://foo.example.com/efgh", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), new MediaInfo("http://foo.example.com/efgh"), }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(0, thumbbox.scrollBar.Minimum); Assert.Equal(1, thumbbox.scrollBar.Maximum); thumbbox.scrollBar.Value = 0; thumbbox.ScrollDown(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollDown(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollUp(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); thumbbox.ScrollUp(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); } }
public void ScrollTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://foo.example.com/efgh", Media = new Dictionary <string, string> { { "http://foo.example.com/abcd", "http://foo.example.com/abcd" }, { "http://foo.example.com/efgh", "http://foo.example.com/efgh" }, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.That(thumbbox.scrollBar.Minimum, Is.EqualTo(0)); Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(1)); thumbbox.scrollBar.Value = 0; thumbbox.ScrollUp(); Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(1)); Assert.That(thumbbox.pictureBox[0].Visible, Is.False); Assert.That(thumbbox.pictureBox[1].Visible, Is.True); thumbbox.ScrollUp(); Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(1)); Assert.That(thumbbox.pictureBox[0].Visible, Is.False); Assert.That(thumbbox.pictureBox[1].Visible, Is.True); thumbbox.ScrollDown(); Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(0)); Assert.That(thumbbox.pictureBox[0].Visible, Is.True); Assert.That(thumbbox.pictureBox[1].Visible, Is.False); thumbbox.ScrollDown(); Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(0)); Assert.That(thumbbox.pictureBox[0].Visible, Is.True); Assert.That(thumbbox.pictureBox[1].Visible, Is.False); } }
public async Task ThumbnailLoadingEventTest() { using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); bool eventCalled; thumbbox.ThumbnailLoading += (s, e) => { eventCalled = true; }; var post = new PostClass { TextFromApi = "てすと", Media = new List <MediaInfo> { }, }; eventCalled = false; await thumbbox.ShowThumbnailAsync(post); Assert.False(eventCalled); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var post2 = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; eventCalled = false; await thumbbox.ShowThumbnailAsync(post2); Assert.True(eventCalled); } }
public void SetThumbnailCountTest( [Values(0, 1, 2)] int count) { using (var thumbbox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("SetThumbnailCount", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(thumbbox, new[] { (object)count }); Assert.That(thumbbox.pictureBox.Count, Is.EqualTo(count)); var num = 0; foreach (var picbox in thumbbox.pictureBox) { Assert.That(picbox.Name, Is.EqualTo("pictureBox" + num)); num++; } Assert.That(thumbbox.panelPictureBox.Controls, Is.EquivalentTo(thumbbox.pictureBox)); Assert.That(thumbbox.scrollBar.Minimum, Is.EqualTo(0)); Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(count)); } }
public async Task ThumbnailLoadingEventTest() { using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var post = new PostClass { TextFromApi = "てすと", Media = new List <MediaInfo> { }, }; await TestUtils.NotRaisesAsync <EventArgs>( x => thumbbox.ThumbnailLoading += x, x => thumbbox.ThumbnailLoading -= x, () => thumbbox.ShowThumbnailAsync(post) ); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var post2 = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; await Assert.RaisesAsync <EventArgs>( x => thumbbox.ThumbnailLoading += x, x => thumbbox.ThumbnailLoading -= x, () => thumbbox.ShowThumbnailAsync(post2) ); } }
public async Task CancelAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List <MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; using (var thumbbox = new TweetThumbnail()) using (var tokenSource = new CancellationTokenSource()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var task = thumbbox.ShowThumbnailAsync(post, tokenSource.Token); tokenSource.Cancel(); await TestUtils.ThrowsAnyAsync <OperationCanceledException>(async() => await task); Assert.True(task.IsCanceled); } }
public void ThumbnailLoadingEventTest() { using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); bool eventCalled; thumbbox.ThumbnailLoading += (s, e) => { eventCalled = true; }; var post = new PostClass { TextFromApi = "てすと", Media = new Dictionary <string, string> { }, }; eventCalled = false; thumbbox.ShowThumbnailAsync(post).Wait(); Assert.That(eventCalled, Is.False); var post2 = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new Dictionary <string, string> { { "http://foo.example.com/abcd", "http://foo.example.com/abcd" }, }, }; eventCalled = false; thumbbox.ShowThumbnailAsync(post2).Wait(); Assert.That(eventCalled, Is.True); } }
public async Task ShowThumbnailAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List<string> { "http://foo.example.com/abcd", }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(0, thumbbox.scrollBar.Maximum); Assert.False(thumbbox.scrollBar.Enabled); Assert.Equal(1, thumbbox.pictureBox.Count); Assert.NotNull(thumbbox.pictureBox[0].Image); Assert.IsAssignableFrom<ThumbnailInfo>(thumbbox.pictureBox[0].Tag); var thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[0].Tag; Assert.Equal("http://foo.example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("dot.gif", thumbinfo.ThumbnailUrl); Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0])); } }
public void SetThumbnailCountTest(int count) { using (var thumbbox = new TweetThumbnail()) { var method = typeof(TweetThumbnail).GetMethod("SetThumbnailCount", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(thumbbox, new[] { (object)count }); Assert.Equal(count, thumbbox.pictureBox.Count); var num = 0; foreach (var picbox in thumbbox.pictureBox) { Assert.Equal("pictureBox" + num, picbox.Name); num++; } Assert.Equal(thumbbox.pictureBox, thumbbox.panelPictureBox.Controls.Cast<OTPictureBox>()); Assert.Equal(0, thumbbox.scrollBar.Minimum); Assert.Equal(count, thumbbox.scrollBar.Maximum); } }
public async Task ShowThumbnailAsyncTest2() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://bar.example.com/efgh", Media = new List<MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), new MediaInfo("http://bar.example.com/efgh"), }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(1, thumbbox.scrollBar.Maximum); Assert.True(thumbbox.scrollBar.Enabled); Assert.Equal(2, thumbbox.pictureBox.Count); Assert.NotNull(thumbbox.pictureBox[0].Image); Assert.NotNull(thumbbox.pictureBox[1].Image); Assert.IsAssignableFrom<ThumbnailInfo>(thumbbox.pictureBox[0].Tag); var thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[0].Tag; Assert.Equal("http://foo.example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("http://img.example.com/abcd.png", thumbinfo.ThumbnailUrl); Assert.IsAssignableFrom<ThumbnailInfo>(thumbbox.pictureBox[1].Tag); thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[1].Tag; Assert.Equal("http://bar.example.com/efgh", thumbinfo.ImageUrl); Assert.Equal("http://img.example.com/efgh.png", thumbinfo.ThumbnailUrl); Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0])); Assert.Equal("efgh", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[1])); } }
public async Task CancelAsyncTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List<MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; using (var thumbbox = new TweetThumbnail()) using (var tokenSource = new CancellationTokenSource()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var task = thumbbox.ShowThumbnailAsync(post, tokenSource.Token); tokenSource.Cancel(); await TestUtils.ThrowsAnyAsync<OperationCanceledException>(async () => await task); Assert.True(task.IsCanceled); } }
public void ShowThumbnailAsyncTest2() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://bar.example.com/efgh", Media = new Dictionary<string, string> { {"http://foo.example.com/abcd", "http://foo.example.com/abcd"}, {"http://bar.example.com/efgh", "http://bar.example.com/efgh"}, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(1)); Assert.That(thumbbox.scrollBar.Enabled, Is.True); Assert.That(thumbbox.pictureBox.Count, Is.EqualTo(2)); Assert.That(thumbbox.pictureBox[0].ImageLocation, Is.EqualTo("dot.gif")); Assert.That(thumbbox.pictureBox[1].ImageLocation, Is.EqualTo("dot.gif")); var thumbinfo = thumbbox.pictureBox[0].Tag as ThumbnailInfo; Assert.That(thumbinfo, Is.Not.Null); Assert.That(thumbinfo.ImageUrl, Is.EqualTo("http://foo.example.com/abcd")); Assert.That(thumbinfo.ThumbnailUrl, Is.EqualTo("dot.gif")); thumbinfo = thumbbox.pictureBox[1].Tag as ThumbnailInfo; Assert.That(thumbinfo, Is.Not.Null); Assert.That(thumbinfo.ImageUrl, Is.EqualTo("http://bar.example.com/efgh")); Assert.That(thumbinfo.ThumbnailUrl, Is.EqualTo("dot.gif")); Assert.That(thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0]), Is.EqualTo("")); Assert.That(thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[1]), Is.EqualTo("efgh")); } }
public void ThumbnailLoadingEventTest() { using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); bool eventCalled; thumbbox.ThumbnailLoading += (s, e) => { eventCalled = true; }; var post = new PostClass { TextFromApi = "てすと", Media = new Dictionary<string, string> { }, }; eventCalled = false; thumbbox.ShowThumbnailAsync(post).Wait(); Assert.False(eventCalled); var post2 = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new Dictionary<string, string> { {"http://foo.example.com/abcd", "http://foo.example.com/abcd"}, }, }; eventCalled = false; thumbbox.ShowThumbnailAsync(post2).Wait(); Assert.True(eventCalled); } }
public async Task ScrollTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://foo.example.com/efgh", Media = new List<MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), new MediaInfo("http://foo.example.com/efgh"), }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); await thumbbox.ShowThumbnailAsync(post); Assert.Equal(0, thumbbox.scrollBar.Minimum); Assert.Equal(1, thumbbox.scrollBar.Maximum); thumbbox.scrollBar.Value = 0; thumbbox.ScrollDown(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollDown(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollUp(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); thumbbox.ScrollUp(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); } }
public void ScrollTest() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://foo.example.com/efgh", Media = new Dictionary<string, string> { {"http://foo.example.com/abcd", "http://foo.example.com/abcd"}, {"http://foo.example.com/efgh", "http://foo.example.com/efgh"}, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.Equal(0, thumbbox.scrollBar.Minimum); Assert.Equal(1, thumbbox.scrollBar.Maximum); thumbbox.scrollBar.Value = 0; thumbbox.ScrollUp(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollUp(); Assert.Equal(1, thumbbox.scrollBar.Value); Assert.False(thumbbox.pictureBox[0].Visible); Assert.True(thumbbox.pictureBox[1].Visible); thumbbox.ScrollDown(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); thumbbox.ScrollDown(); Assert.Equal(0, thumbbox.scrollBar.Value); Assert.True(thumbbox.pictureBox[0].Visible); Assert.False(thumbbox.pictureBox[1].Visible); } }
public void ShowThumbnailAsyncTest2() { var post = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd http://bar.example.com/efgh", Media = new Dictionary<string, string> { {"http://foo.example.com/abcd", "http://foo.example.com/abcd"}, {"http://bar.example.com/efgh", "http://bar.example.com/efgh"}, }, }; using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); thumbbox.ShowThumbnailAsync(post).Wait(); Assert.Equal(1, thumbbox.scrollBar.Maximum); Assert.True(thumbbox.scrollBar.Enabled); Assert.Equal(2, thumbbox.pictureBox.Count); Assert.Equal("dot.gif", thumbbox.pictureBox[0].ImageLocation); Assert.Equal("dot.gif", thumbbox.pictureBox[1].ImageLocation); Assert.IsType<ThumbnailInfo>(thumbbox.pictureBox[0].Tag); var thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[0].Tag; Assert.Equal("http://foo.example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("dot.gif", thumbinfo.ThumbnailUrl); Assert.IsType<ThumbnailInfo>(thumbbox.pictureBox[1].Tag); thumbinfo = (ThumbnailInfo)thumbbox.pictureBox[1].Tag; Assert.Equal("http://bar.example.com/efgh", thumbinfo.ImageUrl); Assert.Equal("dot.gif", thumbinfo.ThumbnailUrl); Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[0])); Assert.Equal("efgh", thumbbox.toolTip.GetToolTip(thumbbox.pictureBox[1])); } }
public async Task ThumbnailLoadingEventTest() { using (var thumbbox = new TweetThumbnail()) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); bool eventCalled; thumbbox.ThumbnailLoading += (s, e) => { eventCalled = true; }; var post = new PostClass { TextFromApi = "てすと", Media = new List<MediaInfo> { }, }; eventCalled = false; await thumbbox.ShowThumbnailAsync(post); Assert.False(eventCalled); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); var post2 = new PostClass { TextFromApi = "てすと http://foo.example.com/abcd", Media = new List<MediaInfo> { new MediaInfo("http://foo.example.com/abcd"), }, }; eventCalled = false; await thumbbox.ShowThumbnailAsync(post2); Assert.True(eventCalled); } }