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); }
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); }
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); }
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); }
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(); }
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(); }
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(); }
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(); }