Ejemplo n.º 1
0
        public void Handler_ReturnsNonNullClaim_WhenExists()
        {
            const string authenticationType = DefaultAuthenticationTypes.ApplicationCookie;
            const string claimType = ClaimTypes.GivenName;
            string claimValue = FakeData.String();
            var data = new[]
            {
                new Claim(ClaimTypes.Email, FakeData.Email()),
                new Claim(ClaimTypes.NameIdentifier, FakeData.Id()
                    .ToString(CultureInfo.InvariantCulture)), 
                new Claim(claimType, claimValue), 
            };
            var queries = new Mock<IProcessQueries>(MockBehavior.Strict);
            Expression<Func<ExternalCookieClaims, bool>> expectedQuery = x => x.AuthenticationType == authenticationType;
            queries.Setup(x => x.Execute(It.Is(expectedQuery)))
                .Returns(Task.FromResult(data as IEnumerable<Claim>));
            var handler = new HandleExternalCookieClaimQuery(queries.Object);
            var query = new ExternalCookieClaim(ClaimTypes.GivenName, authenticationType);

            Claim result = handler.Handle(query).Result;

            Assert.NotNull(result);
            result.Type.ShouldEqual(claimType);
            result.Value.ShouldEqual(claimValue);
            queries.Verify(x => x.Execute(It.Is(expectedQuery)), Times.Once);
        }
Ejemplo n.º 2
0
 public void Query_Ctor_SecondArg_SetsAuthenticationType()
 {
     var claimType = FakeData.String();
     var authenticationType = FakeData.String();
     var query = new ExternalCookieClaim(claimType, authenticationType);
     query.AuthenticationType.ShouldEqual(authenticationType);
 }
Ejemplo n.º 3
0
 public void Query_Ctor_SingleArg_SetsAuthenticationType_ToDefaultExternalCookie()
 {
     var claimType = FakeData.String();
     var query = new ExternalCookieClaim(claimType);
     query.AuthenticationType.ShouldEqual(DefaultAuthenticationTypes.ExternalCookie);
 }
Ejemplo n.º 4
0
 public void Query_Ctor_SingleArg_SetsClaimType()
 {
     var claimType = FakeData.String();
     var query = new ExternalCookieClaim(claimType);
     query.ClaimType.ShouldEqual(claimType);
 }