예제 #1
0
        public async Task Query_WhenAuthorize_Success()
        {
            // arrange
            IServiceProvider services = TestHelpers.CreateSchema <CustomPayload>();
            var payload = new CustomPayload {
                Email = "*****@*****.**"
            };
            var token = await TestHelpers.CreateToken(services, payload);

            // act
            IExecutionResult result = await TestHelpers.ExecuteQuery(services, token);

            // assert
            IHttpContextAccessor httpContextAccessor = services.GetService <IHttpContextAccessor>();
            CustomPayload        customPayload       = httpContextAccessor.GetBewitPayload <CustomPayload>();

            new { QueryResult = result, BewitContext = customPayload }.MatchSnapshot();
        }
예제 #2
0
        public async Task BewitContext_GetObjectPayload_Success()
        {
            // arrange
            IServiceProvider services = TestHelpers.CreateSchema <CustomPayload>();
            var payloadContent        = "*****@*****.**";
            var payload = new CustomPayload {
                Email = payloadContent
            };
            var token = await TestHelpers.CreateToken(services, payload);

            await TestHelpers.ExecuteQuery(services, token);

            // act
            CustomPayload context = services.GetService <IHttpContextAccessor>().GetBewitPayload <CustomPayload>();

            // assert
            Assert.NotNull(context);
            Assert.True(context.Email == payloadContent);
        }