Пример #1
0
        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;
        }
Пример #2
0
        private void applyModelExporterOptions(IModelExporter modelExporter)
        {
            normalsCheckBox.Checked = modelExporter.CanExportNormals;
            normalsCheckBox.Enabled = modelExporter.CanExportNormals;

            textureCoordinatesCheckBox.Checked = modelExporter.CanExportTextureCoordinates;
            textureCoordinatesCheckBox.Enabled = modelExporter.CanExportTextureCoordinates;
        }
Пример #3
0
        private void applyModelExporterOptions(IModelExporter modelExporter)
        {
            normalsCheckBox.Checked = modelExporter.CanExportNormals;
            normalsCheckBox.Enabled = modelExporter.CanExportNormals;

            textureCoordinatesCheckBox.Checked = modelExporter.CanExportTextureCoordinates;
            textureCoordinatesCheckBox.Enabled = modelExporter.CanExportTextureCoordinates;
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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);
        }
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        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);
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        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);
        }
Пример #25
0
        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);
        }
Пример #26
0
        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);
        }
Пример #27
0
        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);
        }
Пример #28
0
        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);
        }
Пример #29
0
        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);
        }
Пример #30
0
        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);
        }
Пример #31
0
        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);
        }