예제 #1
0
        public async Task Given_UserExists_When_CreateIdentityAsync_Then_ReturnsClaims()
        {
            // Arrange
            var authenticationType = "Forms";

            // Act
            var result = await _sut.CreateIdentityAsync(TestUser, authenticationType);

            // Assert
            Assert.AreEqual(4, result.Claims.Count());
            var nameIdentifier = result.Claims.FirstOrDefault(a => a.Type == ClaimTypes.NameIdentifier);

            Assert.IsNotNull(nameIdentifier);
            Assert.AreEqual(TestUser.Id.ToString(), nameIdentifier.Value);
            var roleName = result.Claims.FirstOrDefault(a => a.Type == ClaimTypes.Role);

            Assert.IsNotNull(roleName);
            Assert.AreEqual(_testRoleName, roleName.Value);
        }