Example #1
0
        public void Decript_Test()
        {
            #region === ARRANGE ===

            SessionTokenGenerator sessionTokenGenerator = new SessionTokenGenerator("Some Key!");
            SessionToken          expectedToken         = new SessionToken()
            {
                dateTime = new DateTime(2020, 1, 1),
                UUID     = "Some UUID",
                userId   = 55,
                userName = "******"
            };

            string tokenString = "AcTw4K2/YZZ34viuf5skzVmPweTE9qQt7JvEJTTBCd6hXBrI4X/GhRey6TcpjlyjEPoYmz7ABtnIzqwRuCMvkg==";

            #endregion

            #region === ACT ===

            SessionToken result = sessionTokenGenerator.Decrypt(tokenString);

            #endregion

            #region === ASSERT ===

            Assert.AreEqual <DateTime>(expectedToken.dateTime, result.dateTime);
            Assert.AreEqual <int>(expectedToken.daysToExpire, result.daysToExpire);
            Assert.AreEqual <string>(expectedToken.UUID, result.UUID);
            Assert.AreEqual <int>(expectedToken.userId, result.userId);
            Assert.AreEqual <string>(expectedToken.userName, result.userName);

            #endregion
        }