示例#1
0
        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 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(""));
            }
        }
示例#3
0
        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 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);
            }
        }
示例#5
0
        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 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 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 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 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);
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
        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);
                }
        }
示例#12
0
        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 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 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 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);
            }
        }
示例#16
0
        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"));
            }
        }
示例#17
0
        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);
            }
        }
示例#18
0
        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);
            }
        }
示例#19
0
        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);
            }
        }
示例#20
0
        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]));
            }
        }