示例#1
0
        public void GetToken_WithToken_ReturnsValueIfProviderAndNameMatch()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "GetToken should match on both provider and name, but isn't"

            Assert.Null(user.GetTokenValue("wrongProvider", "tokenName"));                // "GetToken should match on loginProvider, but isn't"

            Assert.Null(user.GetTokenValue("loginProvider", "wrongName"));                // "GetToken should match on tokenName, but isn't"
        }
示例#2
0
        public void RemoveToken_OnlyRemovesIfNameAndProviderMatch()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            user.RemoveToken("wrongProvider", "tokenName");
            Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on loginProvider, but isn't"

            user.RemoveToken("loginProvider", "wrongName");
            Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on tokenName, but isn't"

            user.RemoveToken("loginProvider", "tokenName");
            Assert.Null(user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on both loginProvider and tokenName, but isn't"
        }
        public void GetToken_WithToken_ReturnsValueIfProviderAndNameMatch()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            Expect(user.GetTokenValue("loginProvider", "tokenName"),
                   Is.EqualTo("tokenValue"), "GetToken should match on both provider and name, but isn't");

            Expect(user.GetTokenValue("wrongProvider", "tokenName"),
                   Is.Null, "GetToken should match on loginProvider, but isn't");

            Expect(user.GetTokenValue("loginProvider", "wrongName"),
                   Is.Null, "GetToken should match on tokenName, but isn't");
        }
示例#4
0
        public void GetToken_NoTokens_ReturnsNull()
        {
            var user = new IdentityUser();

            var value = user.GetTokenValue("loginProvider", "tokenName");

            Assert.Null(value);
        }
        public void RemoveToken_OnlyRemovesIfNameAndProviderMatch()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            user.RemoveToken("wrongProvider", "tokenName");
            Expect(user.GetTokenValue("loginProvider", "tokenName"),
                   Is.EqualTo("tokenValue"), "RemoveToken should match on loginProvider, but isn't");

            user.RemoveToken("loginProvider", "wrongName");
            Expect(user.GetTokenValue("loginProvider", "tokenName"),
                   Is.EqualTo("tokenValue"), "RemoveToken should match on tokenName, but isn't");

            user.RemoveToken("loginProvider", "tokenName");
            Expect(user.GetTokenValue("loginProvider", "tokenName"),
                   Is.Null, "RemoveToken should match on both loginProvider and tokenName, but isn't");
        }
示例#6
0
        public void SetToken_ReplacesValue()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            user.SetToken("loginProvider", "tokenName", "updatedValue");

            Assert.Equal(1, user.Tokens.Count);
            Assert.Equal("updatedValue", user.GetTokenValue("loginProvider", "tokenName"));
        }
        public void SetToken_ReplacesValue()
        {
            var user = new IdentityUser();

            user.SetToken("loginProvider", "tokenName", "tokenValue");

            user.SetToken("loginProvider", "tokenName", "updatedValue");

            Expect(user.Tokens.Count, Is.EqualTo(1));
            Expect(user.GetTokenValue("loginProvider", "tokenName"),
                   Is.EqualTo("updatedValue"));
        }