예제 #1
0
        public async Task BuildAsync_WhenCalledAndRedditAuthenticatedUserToObjectViewModelBuilderThrowsAggregateException_AddsExceptionToSystemViewModelsInDashboardViewModel()
        {
            IEnumerable <INews>            newsCollection            = CreateNewsCollection(0);
            IEnumerable <ISystemError>     systemErrorCollection     = CreateSystemErrorCollection(0);
            IRedditAuthenticatedUser       redditAuthenticatedUser   = CreateRedditAuthenticatedUser();
            IEnumerable <IRedditSubreddit> redditSubredditCollection = CreateRedditSubredditCollection(0);
            IEnumerable <IRedditLink>      redditLinkCollection      = CreateRedditLinkCollection(0);
            IDashboard dashboard = CreateDashboard(newsCollection: newsCollection, systemErrorCollection: systemErrorCollection, redditAuthenticatedUser: redditAuthenticatedUser, redditSubredditCollection: redditSubredditCollection, redditLinkCollection: redditLinkCollection);

            string aggregateExceptionMessage = Guid.NewGuid().ToString();
            IViewModelBuilder <DashboardViewModel, IDashboard> sut = CreateSut(aggregateExceptionMessage: aggregateExceptionMessage);

            DashboardViewModel result = await sut.BuildAsync(dashboard);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Informations);
            Assert.AreEqual(0, result.Informations.Count());
            Assert.IsNotNull(result.LatestInformationsWithImage);
            Assert.AreEqual(0, result.LatestInformationsWithImage.Count());
            Assert.IsNotNull(result.SystemErrors);
            Assert.AreEqual(1, result.SystemErrors.Count());
            Assert.IsNull(result.Settings);
            Assert.IsNull(result.RedditAuthenticatedUser);
            Assert.IsNotNull(result.RedditSubreddits);
            Assert.AreEqual(0, result.RedditSubreddits.Count());

            SystemErrorViewModel systemErrorViewModel = result.SystemErrors.First();

            Assert.IsNotNull(systemErrorViewModel);
            Assert.IsNotNull(systemErrorViewModel.SystemErrorIdentifier);
            Assert.IsTrue(systemErrorViewModel.Timestamp >= DateTime.Now.AddSeconds(-3) && systemErrorViewModel.Timestamp <= DateTime.Now);
            Assert.IsNotNull(systemErrorViewModel.Message);
            Assert.AreEqual($"HtmlHelper.ConvertNewLines:{aggregateExceptionMessage}", systemErrorViewModel.Message);
            Assert.IsNotNull(systemErrorViewModel.Details);
        }
예제 #2
0
        public async Task BuildAsync_WhenCalled_ReturnsInitializedDashboardViewModel()
        {
            List <INews>             newsCollection            = CreateNewsCollection(_random.Next(50, 75)).ToList();
            List <ISystemError>      systemErrorCollection     = CreateSystemErrorCollection(_random.Next(10, 15)).ToList();
            IDashboardSettings       dashboardSettings         = CreateDashboardSettings();
            IRedditAuthenticatedUser redditAuthenticatedUser   = CreateRedditAuthenticatedUser();
            List <IRedditSubreddit>  redditSubredditCollection = CreateRedditSubredditCollection(_random.Next(10, 25)).ToList();
            List <IRedditLink>       redditLinkCollection      = CreateRedditLinkCollection(_random.Next(50, 75)).ToList();
            IDashboard dashboard = CreateDashboard(newsCollection: newsCollection, systemErrorCollection: systemErrorCollection, dashboardSettings: dashboardSettings, redditAuthenticatedUser: redditAuthenticatedUser, redditSubredditCollection: redditSubredditCollection, redditLinkCollection: redditLinkCollection);

            DashboardSettingsViewModel dashboardSettingsViewModel = CreateDashboardSettingsViewModel();
            ObjectViewModel <IRedditAuthenticatedUser>         objectViewModelForRedditAuthenticatedUser = CreateObjectViewModel <IRedditAuthenticatedUser>(redditAuthenticatedUser, DateTime.Now.AddDays(_random.Next(1, 365) * -1).AddMinutes(_random.Next(-120, 120)));
            IViewModelBuilder <DashboardViewModel, IDashboard> sut = CreateSut(dashboardSettingsViewModel: dashboardSettingsViewModel, objectViewModelForRedditAuthenticatedUser: objectViewModelForRedditAuthenticatedUser);

            DashboardViewModel result = await sut.BuildAsync(dashboard);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Informations);
            Assert.AreEqual(newsCollection.Count + redditLinkCollection.Count, result.Informations.Count());
            Assert.IsNotNull(result.LatestInformationsWithImage);
            Assert.AreEqual(Math.Min(result.Informations.Count(information => string.IsNullOrWhiteSpace(information.ImageUrl) == false), 7), result.LatestInformationsWithImage.Count());
            Assert.IsNotNull(result.SystemErrors);
            Assert.AreEqual(systemErrorCollection.Count, result.SystemErrors.Count());
            Assert.IsNotNull(result.Settings);
            Assert.AreEqual(dashboardSettingsViewModel, result.Settings);
            Assert.IsNotNull(result.RedditAuthenticatedUser);
            Assert.AreEqual(objectViewModelForRedditAuthenticatedUser, result.RedditAuthenticatedUser);
            Assert.IsNotNull(result.RedditSubreddits);
            Assert.AreEqual(redditSubredditCollection.Count, result.RedditSubreddits.Count());
        }
예제 #3
0
        public void AllowNsfwContent_WhenRedditAuthenticatedUserIsNull_ReturnsFalse()
        {
            const IRedditAuthenticatedUser redditAuthenticatedUser = null;

            IDashboardRules sut = CreateSut(redditAuthenticatedUser);

            Assert.IsFalse(sut.AllowNsfwContent);
        }
예제 #4
0
        public void Replace_WhenCalledWithRedditAuthenticatedUserEqualToNull_ThrowsArgumentNullExcpetion()
        {
            const IRedditAuthenticatedUser redditAuthenticatedUser = null;

            IDashboard sut = CreateSut();

            sut.Replace(redditAuthenticatedUser);
        }
예제 #5
0
        public void Replace(IRedditAuthenticatedUser redditAuthenticatedUser)
        {
            if (redditAuthenticatedUser == null)
            {
                throw new ArgumentNullException(nameof(redditAuthenticatedUser));
            }

            _redditAuthenticatedUser = redditAuthenticatedUser;
        }
예제 #6
0
        public void AllowNsfwContent_WhenRedditAuthenticatedUserIsOver18_ReturnsTrue()
        {
            const bool over18 = true;
            IRedditAuthenticatedUser redditAuthenticatedUser = CreateRedditAuthenticatedUser(over18: over18);

            IDashboardRules sut = CreateSut(redditAuthenticatedUser);

            Assert.IsTrue(sut.AllowNsfwContent);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
0
        public async Task BuildAsync_WhenCalled_AssertBuildAsyncWasCalledOnRedditAuthenticatedUserToObjectViewModelBuilderWithRedditAuthenticatedUserInDashboard()
        {
            IRedditAuthenticatedUser redditAuthenticatedUser = CreateRedditAuthenticatedUser();
            IDashboard dashboard = CreateDashboard(redditAuthenticatedUser: redditAuthenticatedUser);

            IViewModelBuilder <DashboardViewModel, IDashboard> sut = CreateSut();

            await sut.BuildAsync(dashboard);

            _redditAuthenticatedUserToObjectViewModelBuilderMock.Verify(m => m.BuildAsync(It.Is <IRedditAuthenticatedUser>(value => value == redditAuthenticatedUser)), Times.Once);
        }
예제 #11
0
        public async Task ExportAsync_WhenCalled_ReturnsDashboardItemExportModelWithInformationFromRedditAuthenticatedUser()
        {
            IModelExporter <DashboardItemExportModel, IRedditAuthenticatedUser> sut = CreateSut();

            string userName = Guid.NewGuid().ToString("D");
            IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser(userName: userName);
            DashboardItemExportModel result = await sut.ExportAsync(redditAuthenticatedUser);

            Assert.IsNotNull(result);
            Assert.AreEqual(userName, result.Information);
        }
예제 #12
0
        public async Task ExportAsync_WhenCalled_ReturnsDashboardItemExportModelWithTimestampFromRedditAuthenticatedUser()
        {
            IModelExporter <DashboardItemExportModel, IRedditAuthenticatedUser> sut = CreateSut();

            DateTime createdTime = DateTime.Now.AddSeconds(_random.Next(300, 3600) * -1);
            IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser(createdTime: createdTime);
            DashboardItemExportModel result = await sut.ExportAsync(redditAuthenticatedUser);

            Assert.IsNotNull(result);
            Assert.AreEqual(createdTime, result.Timestamp);
        }
예제 #13
0
        public async Task BuildAsync_WhenCalled_AssertRedditAuthenticatedUserWasCalledOnDashboardOnce()
        {
            IRedditAuthenticatedUser redditAuthenticatedUser = CreateRedditAuthenticatedUser();
            Mock <IDashboard>        dashboardMock           = CreateDashboardMock(redditAuthenticatedUser: redditAuthenticatedUser);

            IViewModelBuilder <DashboardViewModel, IDashboard> sut = CreateSut();

            await sut.BuildAsync(dashboardMock.Object);

            dashboardMock.Verify(m => m.RedditAuthenticatedUser, Times.Once);
        }
예제 #14
0
        public async Task GetAuthenticatedUserAsync_WhenCalledAndRedditRateLimitHasExceeded_ReturnsNull()
        {
            IRedditAccessToken redditAccessToken = CreateRedditAccessToken();

            const bool   willExceedRateLimit = true;
            IRedditLogic sut = CreateSut(willExceedRateLimit: willExceedRateLimit);

            IRedditAuthenticatedUser getAuthenticatedUser = await sut.GetAuthenticatedUserAsync(redditAccessToken);

            Assert.IsNull(getAuthenticatedUser);
        }
예제 #15
0
        public async Task GetAuthenticatedUserAsync_WhenCalledAndRedditRateLimitHasNotExceededAndExceptionOccurs_ReturnsNull()
        {
            IRedditAccessToken redditAccessToken = CreateRedditAccessToken();

            const bool   willExceedRateLimit = false;
            Exception    exception           = new Exception();
            IRedditLogic sut = CreateSut(willExceedRateLimit: willExceedRateLimit, exception: exception);

            IRedditAuthenticatedUser getAuthenticatedUser = await sut.GetAuthenticatedUserAsync(redditAccessToken);

            Assert.IsNull(getAuthenticatedUser);
        }
예제 #16
0
        private Task <DashboardItemExportModel>[] CreateExportTasks(IRedditAuthenticatedUser redditAuthenticatedUser)
        {
            if (redditAuthenticatedUser == null)
            {
                return(new Task <DashboardItemExportModel> [0]);
            }

            return(new Task <DashboardItemExportModel>[1]
            {
                _redditAuthenticatedUserModelExporter.ExportAsync(redditAuthenticatedUser)
            });
        }
예제 #17
0
        public async Task GetAuthenticatedUserAsync_WhenCalledAndRedditRateLimitHasNotExceeded_ReturnsRedditAuthenticatedUserFromRedditRepository()
        {
            IRedditAccessToken redditAccessToken = CreateRedditAccessToken();

            const bool willExceedRateLimit = false;
            IRedditAuthenticatedUser redditAuthenticatedUser          = CreateRedditAuthenticatedUser();
            IRedditResponse <IRedditAuthenticatedUser> redditResponse = CreateRedditResponse(redditAuthenticatedUser: redditAuthenticatedUser);
            IRedditLogic sut = CreateSut(willExceedRateLimit: willExceedRateLimit, redditResponse: redditResponse);

            IRedditAuthenticatedUser getAuthenticatedUser = await sut.GetAuthenticatedUserAsync(redditAccessToken);

            Assert.AreEqual(redditAuthenticatedUser, getAuthenticatedUser);
        }
        public async Task BuildAsync(IDashboardSettings dashboardSettings, IDashboard dashboard)
        {
            if (dashboardSettings == null)
            {
                throw new ArgumentNullException(nameof(dashboardSettings));
            }
            if (dashboard == null)
            {
                throw new ArgumentNullException(nameof(dashboard));
            }

            try
            {
                IRedditAccessToken accessToken = dashboardSettings.RedditAccessToken;
                if (DateTime.Now > accessToken.Expires)
                {
                    accessToken = await _redditLogic.RenewAccessTokenAsync(accessToken);

                    if (accessToken == null)
                    {
                        return;
                    }
                    dashboardSettings.RedditAccessToken = accessToken;
                }

                IRedditAuthenticatedUser authenticatedUser = await _redditLogic.GetAuthenticatedUserAsync(accessToken);

                if (authenticatedUser == null)
                {
                    return;
                }
                dashboard.Replace(authenticatedUser);

                bool over18             = authenticatedUser.Over18;
                bool includeNsfwContent = dashboardSettings.IncludeNsfwContent;
                bool onlyNsfwContent    = dashboardSettings.OnlyNsfwContent;
                IEnumerable <IRedditSubreddit> subreddits = await GetSubredditsAsync(accessToken, over18, includeNsfwContent, onlyNsfwContent);

                dashboard.Replace(subreddits);

                IEnumerable <IRedditLink> links = await GetLinksAsync(accessToken, subreddits, over18, includeNsfwContent, onlyNsfwContent);

                dashboard.Replace(links);
            }
            catch (Exception ex)
            {
                await _exceptionHandler.HandleAsync(ex);
            }
        }
예제 #19
0
        public async Task ExportAsync_WhenCalled_ReturnsDashboardExportModelWithContent()
        {
            IModelExporter <DashboardExportModel, IDashboard> sut = CreateSut();

            INews[] newsCollection = BuildNewsCollection().ToArray();
            IRedditAuthenticatedUser redditAuthenticatedUser = BuildRedditAuthenticatedUser();

            IRedditSubreddit[]   redditSubredditCollection = BuildRedditSubredditCollection().ToArray();
            IRedditLink[]        redditLinkCollection      = BuildRedditLinkCollection().ToArray();
            IDashboard           dashboard = BuildDashboard(newsCollection: newsCollection, redditAuthenticatedUser: redditAuthenticatedUser, redditSubredditCollection: redditSubredditCollection, redditLinkCollection: redditLinkCollection);
            DashboardExportModel result    = await sut.ExportAsync(dashboard);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Items);
            Assert.AreEqual(newsCollection.Length + 1 + redditSubredditCollection.Length + redditLinkCollection.Length, result.Items.Count);
        }
예제 #20
0
        public async Task BuildAsync_WhenCalledWithRedditAuthenticatedUserWithoutUnreadMail_ReturnsInitializedObjectViewModelWithCorrectHtml()
        {
            string     userName      = Guid.NewGuid().ToString("D");
            int        commentKarma  = GetKarmaValue();
            int        linkKarma     = GetKarmaValue();
            const bool hasUnreadMail = false;
            IRedditAuthenticatedUser redditAuthenticatedUser = CreateRedditAuthenticatedUser(userName: userName, commentKarma: commentKarma, linkKarma: linkKarma, hasUnreadMail: hasUnreadMail);

            IViewModelBuilder <ObjectViewModel <IRedditAuthenticatedUser>, IRedditAuthenticatedUser> sut = CreateSut();

            ObjectViewModel <IRedditAuthenticatedUser> result = await sut.BuildAsync(redditAuthenticatedUser);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Html);
            Assert.AreEqual(GetExpectedHtml(userName, commentKarma, linkKarma, hasUnreadMail), result.Html);
        }
예제 #21
0
        public async Task BuildAsync_WhenCalled_AssertToCookieWasCalledOnCookieHelperWithDashboardViewModel()
        {
            List <INews>             newsCollection            = CreateNewsCollection(_random.Next(50, 75)).ToList();
            List <ISystemError>      systemErrorCollection     = CreateSystemErrorCollection(_random.Next(10, 15)).ToList();
            IDashboardSettings       dashboardSettings         = CreateDashboardSettings();
            IRedditAuthenticatedUser redditAuthenticatedUser   = CreateRedditAuthenticatedUser();
            List <IRedditSubreddit>  redditSubredditCollection = CreateRedditSubredditCollection(_random.Next(10, 25)).ToList();
            List <IRedditLink>       redditLinkCollection      = CreateRedditLinkCollection(_random.Next(50, 75)).ToList();
            IDashboard dashboard = CreateDashboard(newsCollection: newsCollection, systemErrorCollection: systemErrorCollection, dashboardSettings: dashboardSettings, redditAuthenticatedUser: redditAuthenticatedUser, redditSubredditCollection: redditSubredditCollection, redditLinkCollection: redditLinkCollection);

            DashboardSettingsViewModel dashboardSettingsViewModel = CreateDashboardSettingsViewModel();
            ObjectViewModel <IRedditAuthenticatedUser>         objectViewModelForRedditAuthenticatedUser = CreateObjectViewModel <IRedditAuthenticatedUser>(redditAuthenticatedUser, DateTime.Now.AddDays(_random.Next(1, 365) * -1).AddMinutes(_random.Next(-120, 120)));
            IViewModelBuilder <DashboardViewModel, IDashboard> sut = CreateSut(dashboardSettingsViewModel: dashboardSettingsViewModel, objectViewModelForRedditAuthenticatedUser: objectViewModelForRedditAuthenticatedUser);

            DashboardViewModel result = await sut.BuildAsync(dashboard);

            _cookieHelperMock.Verify(m => m.ToCookie(It.Is <DashboardViewModel>(value => value == result)), Times.Once);
        }
예제 #22
0
        public async Task BuildAsync_WhenCalled_ReturnsInitializedObjectViewModel()
        {
            string   identifier    = Guid.NewGuid().ToString("D");
            DateTime createdTime   = DateTime.Now.AddDays(_random.Next(1, 365) * -1).AddMinutes(_random.Next(-120, 120));
            string   userName      = Guid.NewGuid().ToString("D");
            int      commentKarma  = GetKarmaValue();
            int      linkKarma     = GetKarmaValue();
            bool     hasUnreadMail = _random.Next(1, 100) > 50;
            IRedditAuthenticatedUser redditAuthenticatedUser = CreateRedditAuthenticatedUser(identifier, createdTime, userName, commentKarma, linkKarma, hasUnreadMail);

            IViewModelBuilder <ObjectViewModel <IRedditAuthenticatedUser>, IRedditAuthenticatedUser> sut = CreateSut();

            ObjectViewModel <IRedditAuthenticatedUser> result = await sut.BuildAsync(redditAuthenticatedUser);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ObjectIdentifier);
            Assert.AreEqual(identifier, result.ObjectIdentifier);
            Assert.IsNotNull(result.Object);
            Assert.AreEqual(redditAuthenticatedUser, result.Object);
            Assert.AreEqual(createdTime, result.Timestamp);
            Assert.IsNotNull(result.Html);
            Assert.AreEqual(GetExpectedHtml(userName, commentKarma, linkKarma, hasUnreadMail), result.Html);
        }
예제 #23
0
        private Mock <IDashboard> CreateDashboardMock(IEnumerable <INews> newsCollection = null, IEnumerable <ISystemError> systemErrorCollection = null, IDashboardSettings dashboardSettings = null, IRedditAuthenticatedUser redditAuthenticatedUser = null, IEnumerable <IRedditSubreddit> redditSubredditCollection = null, IEnumerable <IRedditLink> redditLinkCollection = null, IDashboardRules dashboardRules = null)
        {
            Mock <IDashboard> dashboardMock = new Mock <IDashboard>();

            dashboardMock.Setup(m => m.News)
            .Returns(newsCollection ?? CreateNewsCollection(_random.Next(50, 100)));
            dashboardMock.Setup(m => m.SystemErrors)
            .Returns(systemErrorCollection ?? CreateSystemErrorCollection(_random.Next(5, 10)));
            dashboardMock.Setup(m => m.Settings)
            .Returns(dashboardSettings);
            dashboardMock.Setup(m => m.RedditAuthenticatedUser)
            .Returns(redditAuthenticatedUser);
            dashboardMock.Setup(m => m.RedditSubreddits)
            .Returns(redditSubredditCollection ?? CreateRedditSubredditCollection(_random.Next(10, 25)));
            dashboardMock.Setup(m => m.RedditLinks)
            .Returns(redditLinkCollection ?? CreateRedditLinkCollection(_random.Next(50, 100)));
            dashboardMock.Setup(m => m.Rules)
            .Returns(dashboardRules ?? CreateDashboardRules());
            return(dashboardMock);
        }
예제 #24
0
 private IDashboard CreateDashboard(IEnumerable <INews> newsCollection = null, IEnumerable <ISystemError> systemErrorCollection = null, IDashboardSettings dashboardSettings = null, IRedditAuthenticatedUser redditAuthenticatedUser = null, IEnumerable <IRedditSubreddit> redditSubredditCollection = null, IEnumerable <IRedditLink> redditLinkCollection = null, IDashboardRules dashboardRules = null)
 {
     return(CreateDashboardMock(newsCollection, systemErrorCollection, dashboardSettings, redditAuthenticatedUser, redditSubredditCollection, redditLinkCollection, dashboardRules).Object);
 }
예제 #25
0
 private IDashboardRules CreateSut(IRedditAuthenticatedUser redditAuthenticatedUser)
 {
     return(new OSDevGrp.MyDashboard.Core.Models.DashboardRules(redditAuthenticatedUser));
 }
예제 #26
0
        private Mock <IRedditResponse <IRedditAuthenticatedUser> > CreateRedditResponseMock(int?rateLimitUsed = null, int?rateLimitRemaining = null, DateTime?rateLimitResetTime = null, DateTime?receivedTime = null, IRedditAuthenticatedUser redditAuthenticatedUser = null)
        {
            Mock <IRedditResponse <IRedditAuthenticatedUser> > redditResponseMock = new Mock <IRedditResponse <IRedditAuthenticatedUser> >();

            redditResponseMock.Setup(m => m.RateLimitUsed)
            .Returns(rateLimitUsed ?? _random.Next(1, 60));
            redditResponseMock.Setup(m => m.RateLimitRemaining)
            .Returns(rateLimitRemaining ?? _random.Next(1, 60));
            redditResponseMock.Setup(m => m.RateLimitResetTime)
            .Returns(rateLimitResetTime ?? DateTime.Now.AddSeconds(_random.Next(30, 60)));
            redditResponseMock.Setup(m => m.ReceivedTime)
            .Returns(receivedTime ?? DateTime.Now.AddSeconds(_random.Next(1, 10) * -1));
            redditResponseMock.Setup(m => m.Data)
            .Returns(redditAuthenticatedUser ?? CreateRedditAuthenticatedUser());
            return(redditResponseMock);
        }
예제 #27
0
 private IRedditResponse <IRedditAuthenticatedUser> CreateRedditResponse(int?rateLimitUsed = null, int?rateLimitRemaining = null, DateTime?rateLimitResetTime = null, DateTime?receivedTime = null, IRedditAuthenticatedUser redditAuthenticatedUser = null)
 {
     return(CreateRedditResponseMock(rateLimitUsed, rateLimitRemaining, rateLimitResetTime, receivedTime, redditAuthenticatedUser).Object);
 }
예제 #28
0
 private IDashboard BuildDashboard(bool hasNews = true, IEnumerable <INews> newsCollection = null, bool hasRedditAuthenticatedUser = true, IRedditAuthenticatedUser redditAuthenticatedUser = null, bool hasRedditSubreddits = true, IEnumerable <IRedditSubreddit> redditSubredditCollection = null, bool hasRedditLinks = true, IEnumerable <IRedditLink> redditLinkCollection = null)
 {
     return(BuildDashboardMock(hasNews, newsCollection, hasRedditAuthenticatedUser, redditAuthenticatedUser, hasRedditSubreddits, redditSubredditCollection, hasRedditLinks, redditLinkCollection).Object);
 }
 public DashboardRules(IRedditAuthenticatedUser redditAuthenticatedUser)
 {
     _redditAuthenticatedUser = redditAuthenticatedUser;
 }
예제 #30
0
        private Mock <IDashboard> BuildDashboardMock(bool hasNews = true, IEnumerable <INews> newsCollection = null, bool hasRedditAuthenticatedUser = true, IRedditAuthenticatedUser redditAuthenticatedUser = null, bool hasRedditSubreddits = true, IEnumerable <IRedditSubreddit> redditSubredditCollection = null, bool hasRedditLinks = true, IEnumerable <IRedditLink> redditLinkCollection = null)
        {
            Mock <IDashboard> dashboardMock = new Mock <IDashboard>();

            dashboardMock.Setup(m => m.News)
            .Returns(hasNews ? newsCollection ?? BuildNewsCollection() : null);
            dashboardMock.Setup(m => m.RedditAuthenticatedUser)
            .Returns(hasRedditAuthenticatedUser ? redditAuthenticatedUser ?? BuildRedditAuthenticatedUser() : null);
            dashboardMock.Setup(m => m.RedditSubreddits)
            .Returns(hasRedditSubreddits ? redditSubredditCollection ?? BuildRedditSubredditCollection() : null);
            dashboardMock.Setup(m => m.RedditLinks)
            .Returns(hasRedditLinks ? redditLinkCollection ?? BuildRedditLinkCollection() : null);
            return(dashboardMock);
        }