Пример #1
0
        public void ToDashboardSettings_WhenCalledWhereOnlyNsfwContentIsFalse_ReturnsInitializedDashboardSettings()
        {
            const bool onlyNsfwContent = false;

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(onlyNsfwContent: onlyNsfwContent);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsFalse(result.OnlyNsfwContent);
        }
Пример #2
0
        public void ToDashboardSettings_WhenCalledWhereIncludeNsfwContentIsTrue_ReturnsInitializedDashboardSettings()
        {
            const bool includeNsfwContent = true;

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(includeNsfwContent: includeNsfwContent);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsTrue(result.IncludeNsfwContent);
        }
Пример #3
0
        public void ToDashboardSettings_WhenCalledWhereIncludeNsfwContentIsNull_ReturnsInitializedDashboardSettings()
        {
            bool?includeNsfwContent = null;

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(includeNsfwContent: includeNsfwContent);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsFalse(result.IncludeNsfwContent);
        }
Пример #4
0
        public void ToDashboardSettings_WhenCalledWhereRedditAccessTokenIsWhitespaces_ReturnsInitializedDashboardSettings()
        {
            const string redditAccessToken = "  ";

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(redditAccessToken: redditAccessToken);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DashboardSettings));
            Assert.IsNull(result.RedditAccessToken);
        }
Пример #5
0
        public void ToDashboardSettings_WhenCalled_ReturnsInitializedDashboardSettings()
        {
            int    numberOfNews       = _random.Next(25, 50);
            bool   useReddit          = _random.Next(100) > 50;
            bool   includeNsfwContent = _random.Next(100) > 50;
            bool   onlyNsfwContent    = _random.Next(100) > 50;
            string redditAccessToken  = CreateReddditAccessToken().ToBase64();

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(numberOfNews, useReddit, includeNsfwContent, onlyNsfwContent, redditAccessToken);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DashboardSettings));
            Assert.AreEqual(numberOfNews, result.NumberOfNews);
            Assert.AreEqual(useReddit, result.UseReddit);
            Assert.AreEqual(includeNsfwContent, result.IncludeNsfwContent);
            Assert.AreEqual(onlyNsfwContent, result.OnlyNsfwContent);
            Assert.IsNotNull(result.RedditAccessToken);
        }
Пример #6
0
        public void ToDashboardSettings_WhenCalledWhereRedditAccessTokenIsBase64_ReturnsInitializedDashboardSettings()
        {
            string   accessToken       = Guid.NewGuid().ToString("D");
            string   tokenType         = Guid.NewGuid().ToString("D");
            int      expiresIn         = _random.Next(60, 300);
            string   scope             = Guid.NewGuid().ToString("D");
            string   refreshToken      = Guid.NewGuid().ToString("D");
            DateTime received          = DateTime.UtcNow;
            string   redditAccessToken = CreateReddditAccessToken(accessToken, tokenType, expiresIn, scope, refreshToken, received).ToBase64();

            OSDevGrp.MyDashboard.Web.Models.DashboardSettingsViewModel sut = CreateSut(redditAccessToken: redditAccessToken);

            IDashboardSettings result = sut.ToDashboardSettings();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DashboardSettings));
            Assert.IsNotNull(result.RedditAccessToken);
            Assert.IsInstanceOfType(result.RedditAccessToken, typeof(RedditAccessToken));
            Assert.AreEqual(accessToken, result.RedditAccessToken.AccessToken);
            Assert.AreEqual(tokenType, result.RedditAccessToken.TokenType);
            Assert.AreEqual(received.ToLocalTime().AddSeconds(expiresIn).ToString(), result.RedditAccessToken.Expires.ToString());
            Assert.AreEqual(scope, result.RedditAccessToken.Scope);
            Assert.AreEqual(refreshToken, result.RedditAccessToken.RefreshToken);
        }