예제 #1
0
        public void DecodeJwtPayloadTest()
        {
            using (JwtServiceArgs args = new JwtServiceArgs
            {
                Secret = _secret
            })
                using (JwtService service = new JwtService(args))
                {
                    Foobar foobar = new Foobar
                    {
                        Bar = 4,
                        Foo = 1
                    };
                    string baseString = args.Encoder.Encode(foobar, _secret);
                    Foobar expected   = args.Decoder.DecodeToObject <Foobar>(baseString, _secret, true);
                    Foobar actual     = service.DecodeJwtPayload <Foobar>(baseString);

                    Assert.NotEqual(expected, actual);
                    Assert.Equal(expected.Bar, actual.Bar);
                    Assert.Equal(expected.Foo, actual.Foo);
                    Assert.Equal(0, expected.Bar);
                }
        }