public void User_Id_IsRepresentedAsBsonObjectId()
        {
            var user = new IdentityUser();

            var document = user.ToBsonDocument();

            Assert.IsType<BsonObjectId>(document["_id"]);
        }
        public void UserWithoutClaims_MyClaims_AreIgnored()
        {
            var user = new IdentityUser();

            var document = user.ToBsonDocument();

            Assert.False(document.Contains("MyClaims"));
        }
        public void CreateUser_Id_IsAssigned()
        {
            var user = new IdentityUser();

            ObjectId userObjectId = user.Id;

            Assert.NotNull(userObjectId);
            Assert.NotEqual(userObjectId, ObjectId.Empty);
        }
        public void UserWithoutClaims_RemoveClaim_DoesNothing()
        {
            var user = new IdentityUser();

            string claimType = "test-claim";
            string claimValue = "test-value";

            var claim = new Claim(claimType, claimValue);

            user.RemoveClaim(claim);

            Assert.Empty(user.Claims);
        }
        public void UserWithoutClaims_AddClaim_OneClaimAdded()
        {
            var user = new IdentityUser();

            string claimType = "test-claim";
            string claimValue = "test-value";

            var claim = new Claim(claimType, claimValue);

            user.AddClaim(claim);

            Assert.Equal(1, user.Claims.Count);
            Assert.Equal(claimType, user.Claims[0].ClaimType);
            Assert.Equal(claimValue, user.Claims[0].ClaimValue);
        }
        public void UserWithOneClaim_RemoveNonExistingClaim_DoesNothing()
        {
            var user = new IdentityUser();

            string claimType = "test-claim";
            string claimValue = "test-value";

            var claim = new Claim(claimType, claimValue);
            user.AddClaim(claim);

            user.RemoveClaim(new Claim("non-existing-type", "non-existing-value"));

            Assert.Equal(1, user.Claims.Count);
            Assert.Equal(claimType, user.Claims[0].ClaimType);
            Assert.Equal(claimValue, user.Claims[0].ClaimValue);
        }
        public void CreateUser_Claims_NotNull()
        {
            var user = new IdentityUser();

            Assert.NotNull(user.Claims);
        }
        public void CreateUser_Roles_NotNull()
        {
            var user = new IdentityUser();

            Assert.NotNull(user.Roles);
        }
        public void CreateUser_Logins_NotNull()
        {
            var user = new IdentityUser();

            Assert.NotNull(user.Logins);
        }
        public void UserWithTwoClaims_RemoveOneOfTheClaims_OtherClaimRemains()
        {
            var user = new IdentityUser();

            string claimType1 = "test-claim-1";
            string claimValue1 = "test-value-1";
            var claim1 = new Claim(claimType1, claimValue1);

            string claimType2 = "test-claim-2";
            string claimValue2 = "test-value-2";
            var claim2 = new Claim(claimType2, claimValue2);

            user.AddClaim(claim1);
            user.AddClaim(claim2);

            user.RemoveClaim(new Claim(claimType1, claimValue1));

            Assert.Equal(1, user.Claims.Count);
            Assert.Equal(claimType2, user.Claims[0].ClaimType);
            Assert.Equal(claimValue2, user.Claims[0].ClaimValue);
        }
        public void UserWithOneClaim_RemoveTheClaim_NoClaimsRemain()
        {
            var user = new IdentityUser();

            string claimType = "test-claim";
            string claimValue = "test-value";

            var claim1 = new Claim(claimType, claimValue);
            var claim2 = new Claim(claimType, claimValue);

            user.AddClaim(claim1);
            user.RemoveClaim(claim2);

            Assert.Empty(user.Claims);
        }