Exemple #1
0
        public async Task ShouldShowStoryAuthor()
        {
            var sut = new StoryViewModel(Share.Object, Browser.Object, Dialog.Object);

            var story      = new Mock <IStory>();
            var fakeAuthor = "Albert McAuthorFace";

            story.SetupGet(s => s.By).Returns(fakeAuthor);

            sut.Prepare(story.Object);
            await sut.Initialize();

            Assert.Equal(fakeAuthor, sut.Author);
        }
Exemple #2
0
        public async Task ShouldShowCommentsCount()
        {
            var sut = new StoryViewModel(Share.Object, Browser.Object, Dialog.Object);

            var story     = new Mock <IStory>();
            var fakeCount = 111;

            story.SetupGet(s => s.Descendants).Returns(fakeCount);

            sut.Prepare(story.Object);
            await sut.Initialize();

            Assert.Equal(fakeCount, sut.CommentsCount);
        }
Exemple #3
0
        public async Task ShouldShowStoryScore()
        {
            var sut = new StoryViewModel(Share.Object, Browser.Object, Dialog.Object);

            var story     = new Mock <IStory>();
            var fakeScore = 99;

            story.SetupGet(s => s.Score).Returns(fakeScore);

            sut.Prepare(story.Object);
            await sut.Initialize();

            Assert.Equal(fakeScore, sut.Score);
        }
Exemple #4
0
        public async Task ShouldShowStoryUrl()
        {
            var sut = new StoryViewModel(Share.Object, Browser.Object, Dialog.Object);

            var story   = new Mock <IStory>();
            var fakeUrl = "https://fake-url.com";

            story.SetupGet(s => s.Url).Returns(fakeUrl);

            sut.Prepare(story.Object);
            await sut.Initialize();

            Assert.Equal(fakeUrl, sut.StoryUrl);
        }
Exemple #5
0
        public async Task ShareStoryCommandShouldShareStoryUrl()
        {
            var share   = Share;
            var fakeUrl = "https://fake-url.com";

            share.Setup(s => s.ShareLinkAsync(It.IsAny <string>(), fakeUrl, It.IsAny <object>()))
            .ReturnsAsync(true)
            .Verifiable();

            var story = new Mock <IStory>();

            story.SetupGet(s => s.Url).Returns(fakeUrl);

            var sut = new StoryViewModel(share.Object, Browser.Object, Dialog.Object);

            sut.Prepare(story.Object);
            await sut.Initialize();

            sut.ShareStoryCommand.TryExecute();

            share.Verify();
        }
Exemple #6
0
        public async Task OpenInExternalBrowserCommandShouldOpenStoryUrlInExternalBrowser()
        {
            var browser = Browser;
            var fakeUrl = "https://fake-url.com";

            browser.Setup(b => b.ShowInBrowserAsync(new Uri(fakeUrl), false))
            .ReturnsAsync(true)
            .Verifiable();

            var story = new Mock <IStory>();

            story.SetupGet(s => s.Url).Returns(fakeUrl);

            var sut = new StoryViewModel(Share.Object, browser.Object, Dialog.Object);

            sut.Prepare(story.Object);
            await sut.Initialize();

            sut.OpenInExternalBrowserCommand.TryExecute();

            browser.Verify();
        }
Exemple #7
0
        public async Task ShareCommentsCommandShouldShareStoryTitle()
        {
            var share     = Share;
            var fakeTitle = "Fake Story Title";

            share.Setup(s => s.ShareLinkAsync(fakeTitle, It.IsAny <string>(), It.IsAny <object>()))
            .ReturnsAsync(true)
            .Verifiable();

            var story = new Mock <IStory>();

            story.SetupGet(s => s.Title).Returns(fakeTitle);

            var sut = new StoryViewModel(share.Object, Browser.Object, Dialog.Object);

            sut.Prepare(story.Object);
            await sut.Initialize();

            sut.ShareStoryCommand.TryExecute();

            share.Verify();
        }
Exemple #8
0
        public async Task ShareCommentsCommandShouldShareStoryUrl()
        {
            var share   = Share;
            var fakeId  = 999;
            var fakeUrl = $"https://news.ycombinator.com/item?id={fakeId}";

            share.Setup(s => s.ShareLinkAsync(It.IsAny <string>(), fakeUrl, It.IsAny <object>()))
            .ReturnsAsync(true)
            .Verifiable();

            var story = new Mock <IStory>();

            story.SetupGet(s => s.Id).Returns(fakeId);

            var sut = new StoryViewModel(share.Object, Browser.Object, Dialog.Object);

            sut.Prepare(story.Object);
            await sut.Initialize();

            sut.ShareCommentsCommand.TryExecute();

            share.Verify();
        }