public HomeController(IDashboardFactory dashboardFactory, IViewModelBuilder <DashboardViewModel, IDashboard> dashboardViewModelBuilder, IModelExporter <DashboardExportModel, IDashboard> dashboardModelExporter, IRedditAccessTokenProviderFactory redditAccessTokenProviderFactory, IContentHelper contentHelper, ICookieHelper cookieHelper) { if (dashboardFactory == null) { throw new ArgumentNullException(nameof(dashboardFactory)); } if (dashboardViewModelBuilder == null) { throw new ArgumentNullException(nameof(dashboardViewModelBuilder)); } if (dashboardModelExporter == null) { throw new ArgumentNullException(nameof(dashboardModelExporter)); } if (redditAccessTokenProviderFactory == null) { throw new ArgumentNullException(nameof(redditAccessTokenProviderFactory)); } if (contentHelper == null) { throw new ArgumentNullException(nameof(contentHelper)); } if (cookieHelper == null) { throw new ArgumentNullException(nameof(cookieHelper)); } _dashboardFactory = dashboardFactory; _dashboardViewModelBuilder = dashboardViewModelBuilder; _dashboardModelExporter = dashboardModelExporter; _redditAccessTokenProviderFactory = redditAccessTokenProviderFactory; _contentHelper = contentHelper; _cookieHelper = cookieHelper; }
private void applyModelExporterOptions(IModelExporter modelExporter) { normalsCheckBox.Checked = modelExporter.CanExportNormals; normalsCheckBox.Enabled = modelExporter.CanExportNormals; textureCoordinatesCheckBox.Checked = modelExporter.CanExportTextureCoordinates; textureCoordinatesCheckBox.Enabled = modelExporter.CanExportTextureCoordinates; }
public async Task ExportAsync_WhenRedditSubredditIsWithoutDescriptionAsText_AssertPublicDescriptionAsTextWasCalledOnRedditSubreddit() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); Mock <IRedditSubreddit> redditSubredditMock = BuildRedditSubredditMock(); await sut.ExportAsync(redditSubredditMock.Object); redditSubredditMock.Verify(m => m.PublicDescriptionAsText, Times.Once); }
public async Task ExportAsync_WhenRedditSubredditIsWithoutBannerImageUrl_AssertHeaderImageUrllWasCalledOnRedditSubreddit() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); Mock <IRedditSubreddit> redditSubredditMock = BuildRedditSubredditMock(); await sut.ExportAsync(redditSubredditMock.Object); redditSubredditMock.Verify(m => m.HeaderImageUrl, Times.Once); }
public async Task ExportAsync_WhenCalled_AssertProviderWasCalledOnNews() { IModelExporter <DashboardItemExportModel, INews> sut = CreateSut(); Mock <INews> newsMock = BuildNewsMock(); await sut.ExportAsync(newsMock.Object); newsMock.Verify(m => m.Provider, Times.Once); }
public async Task ExportAsync_WhenCalled_AssertRedditAuthenticatedUserWasCalledOnDashboard() { IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut(); Mock <IDashboard> dashboardMock = BuildDashboardMock(); await sut.ExportAsync(dashboardMock.Object); dashboardMock.Verify(m => m.RedditAuthenticatedUser, Times.Once); }
public async Task ExportAsync_WhenRedditLinkIsWithoutImages_AssertThumbnailUrlWasCalledOnRedditLink() { IModelExporter <DashboardItemExportModel, IRedditLink> sut = CreateSut(); Mock <IRedditLink> redditLinkMock = BuildRedditLinkMock(); await sut.ExportAsync(redditLinkMock.Object); redditLinkMock.Verify(m => m.ThumbnailUrl, Times.Once); }
public async Task ExportAsync_WhenCalled_ReturnsResultFromDoExportAsyncOnModelExporter() { IExportModel exportModel = new Mock <IExportModel>().Object; IModelExporter <IExportModel, object> sut = CreateSut(exportModel); IExportModel result = await sut.ExportAsync(new object()); Assert.AreEqual(exportModel, result); }
public async Task ExportAsync_WhenDashboardDoesNotHaveNews_AssertExportAsyncWasNotCalledOnNewsModelExporter() { IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut(); IDashboard dashboard = BuildDashboard(false); await sut.ExportAsync(dashboard); _newsModelExporterMock.Verify(m => m.ExportAsync(It.IsAny <INews>()), Times.Never); }
public async Task ExportAsync_WhenCalled_AssertUserNameWasCalledOnRedditLink() { IModelExporter <DashboardItemExportModel, IRedditAuthenticatedUser> sut = CreateSut(); Mock <IRedditAuthenticatedUser> redditAuthenticatedUserMock = BuildRedditAuthenticatedUserMock(); await sut.ExportAsync(redditAuthenticatedUserMock.Object); redditAuthenticatedUserMock.Verify(m => m.UserName, Times.Once); }
public async Task ExportAsync_WhenDashboardDoesNotHaveRedditLinks_AssertExportAsyncWasNotCalledOnRedditLinkModelExporter() { IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut(); IDashboard dashboard = BuildDashboard(hasRedditLinks: false); await sut.ExportAsync(dashboard); _redditLinkModelExporterMock.Verify(m => m.ExportAsync(It.IsAny <IRedditLink>()), Times.Never); }
public async Task ExportAsync_WhenCalled_AssertSubredditWasCalledOnRedditLink() { IModelExporter <DashboardItemExportModel, IRedditLink> sut = CreateSut(); Mock <IRedditLink> redditLinkMock = BuildRedditLinkMock(); await sut.ExportAsync(redditLinkMock.Object); redditLinkMock.Verify(m => m.Subreddit, Times.Once); }
public async Task ExportAsync_WhenCalled_AssertHandleAsyncWasNotCalledOnExceptionHandler() { IModelExporter <DashboardItemExportModel, IRedditAuthenticatedUser> sut = CreateSut(); IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser(); DashboardItemExportModel result = await sut.ExportAsync(redditAuthenticatedUser); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <AggregateException>()), Times.Never); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <Exception>()), Times.Never); }
public async Task ExportAsync_WhenCalled_ReturnsDashboardItemExportModelWithoutImageUrl() { IModelExporter <DashboardItemExportModel, IRedditAuthenticatedUser> sut = CreateSut(); IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser(); DashboardItemExportModel result = await sut.ExportAsync(redditAuthenticatedUser); Assert.IsNotNull(result); Assert.IsNull(result.ImageUrl); }
public async Task ExportAsync_WhenAggregateExceptionWasThrown_AssertHandleAsyncWasCalledOnExceptionHandler() { AggregateException exception = new AggregateException(); IModelExporter <IExportModel, object> sut = CreateSut(exception: exception); object input = new object(); await sut.ExportAsync(input); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.Is <AggregateException>(value => value == exception)), Times.Once); }
public async Task ExportAsync_WhenDashboardHasRedditAuthenticatedUser_AssertExportAsyncWasCalledOnRedditAuthenticatedUserModelExporter() { IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut(); IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser(); IDashboard dashboard = BuildDashboard(redditAuthenticatedUser: redditAuthenticatedUser); await sut.ExportAsync(dashboard); _redditAuthenticatedUserModelExporterMock.Verify(m => m.ExportAsync(It.Is <IRedditAuthenticatedUser>(value => value == redditAuthenticatedUser)), Times.Once); }
public async Task ExportAsync_WhenCalled_ReturnsDashboardItemExportModelWithoutImageUrl() { IModelExporter <DashboardItemExportModel, INews> sut = CreateSut(); INews news = BuildNews(); DashboardItemExportModel result = await sut.ExportAsync(news); Assert.IsNotNull(result); Assert.IsNull(result.ImageUrl); }
public async Task ExportAsync_WhenNewsIsWithoutAuthor_ReturnsDashboardItemExportModelWithoutAuthor() { IModelExporter <DashboardItemExportModel, INews> sut = CreateSut(); INews news = BuildNews(); DashboardItemExportModel result = await sut.ExportAsync(news); Assert.IsNotNull(result); Assert.IsNull(result.Author); }
public async Task ExportAsync_WhenNewsIsWithAuthor_AssertNameWasCalledOnAuthor() { IModelExporter <DashboardItemExportModel, INews> sut = CreateSut(); Mock <IAuthor> authorMock = BuildAuthorMock(); INews news = BuildNews(author: authorMock.Object); await sut.ExportAsync(news); authorMock.Verify(m => m.Name, Times.Once); }
public async Task ExportAsync_WhenRedditLinkIsWithoutRedditSubreddit_AssertFullNameWasNotCalledOnRedditSubreddit() { IModelExporter <DashboardItemExportModel, IRedditLink> sut = CreateSut(); Mock <IRedditSubreddit> redditSubredditMock = BuildRedditSubredditMock(); IRedditLink redditLink = BuildRedditLink(); await sut.ExportAsync(redditLink); redditSubredditMock.Verify(m => m.FullName, Times.Never); }
public async Task ExportAsync_WhenRedditLinkIsWithoutImagesAndWithoutThumbnailUrl_ReturnsDashboardItemExportModelWithoutImageUrl() { IModelExporter <DashboardItemExportModel, IRedditLink> sut = CreateSut(); IRedditLink redditLink = BuildRedditLink(); DashboardItemExportModel result = await sut.ExportAsync(redditLink); Assert.IsNotNull(result); Assert.IsNull(result.ImageUrl); }
public async Task ExportAsync_WhenRedditLinkIsWithoutAuthor_ReturnsDashboardItemExportModelWithoutAuthor() { IModelExporter <DashboardItemExportModel, IRedditLink> sut = CreateSut(); IRedditLink redditLink = BuildRedditLink(); DashboardItemExportModel result = await sut.ExportAsync(redditLink); Assert.IsNotNull(result); Assert.IsNull(result.Author); }
public async Task ExportAsync_WhenCalled_ReturnsDashboardItemExportModelWithoutAuthor() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); IRedditSubreddit redditSubreddit = BuildRedditSubreddit(); DashboardItemExportModel result = await sut.ExportAsync(redditSubreddit); Assert.IsNotNull(result); Assert.IsNull(result.Author); }
public async Task ExportAsync_WhenRedditSubredditIsWithBannerImageUrl_AssertHeaderImageUrllWasNotCalledOnRedditSubreddit() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); Uri bannerImageUrl = new Uri($"http://localhost/{Guid.NewGuid().ToString("D")}/{Guid.NewGuid().ToString("D")}"); Mock <IRedditSubreddit> redditSubredditMock = BuildRedditSubredditMock(bannerImageUrl: bannerImageUrl); await sut.ExportAsync(redditSubredditMock.Object); redditSubredditMock.Verify(m => m.HeaderImageUrl, Times.Never); }
public async Task ExportAsync_WhenCalled_AssertHandleAsyncWasNotCalledOnExceptionHandler() { IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut(); IDashboard dashboard = BuildDashboard(); await sut.ExportAsync(dashboard); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <AggregateException>()), Times.Never); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <Exception>()), Times.Never); }
public async Task ExportAsync_WhenRedditSubredditIsWithoutBannerImageUrlAndWithoutHeaderImageUrl_ReturnsDashboardItemExportModelWithoutImageUrl() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); IRedditSubreddit redditSubreddit = BuildRedditSubreddit(); DashboardItemExportModel result = await sut.ExportAsync(redditSubreddit); Assert.IsNotNull(result); Assert.IsNull(result.ImageUrl); }
public async Task ExportAsync_WhenExceptionWasThrown_ReturnsResultFromEmptyOnModelExporter() { IExportModel emptyExportModel = new Mock <IExportModel>().Object; Exception exception = new Exception(); IModelExporter <IExportModel, object> sut = CreateSut(emptyExportModel: emptyExportModel, exception: exception); IExportModel result = await sut.ExportAsync(new object()); Assert.AreEqual(emptyExportModel, result); }
public async Task ExportAsync_WhenCalled_AssertHandleAsyncWasNotCalledOnExceptionHandler() { IModelExporter <IExportModel, object> sut = CreateSut(); object input = new object(); await sut.ExportAsync(input); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <AggregateException>()), Times.Never); _exceptionHandlerMock.Verify(m => m.HandleAsync(It.IsAny <Exception>()), Times.Never); }
public async Task ExportAsync_WhenNewsIsWithoutProvider_AssertNameWasNotCalledOnProvider() { IModelExporter <DashboardItemExportModel, INews> sut = CreateSut(); Mock <INewsProvider> newsProviderMock = BuildNewsProviderMock(); INews news = BuildNews(); await sut.ExportAsync(news); newsProviderMock.Verify(m => m.Name, Times.Never); }
public async Task ExportAsync_WhenRedditSubredditIsWithDescriptionAsText_AssertPublicDescriptionAsTextWasNotCalledOnRedditSubreddit() { IModelExporter <DashboardItemExportModel, IRedditSubreddit> sut = CreateSut(); string descriptionAsText = Guid.NewGuid().ToString("D"); Mock <IRedditSubreddit> redditSubredditMock = BuildRedditSubredditMock(descriptionAsText: descriptionAsText); await sut.ExportAsync(redditSubredditMock.Object); redditSubredditMock.Verify(m => m.PublicDescriptionAsText, Times.Never); }