public void FindByIDFact()
        {
            var membership = default(Membership);

            try
            {
                membership = new Membership(new MembershipEntity());

                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (sender, e) => Assert.NotEqual(MembershipEntity.Empty, e);
                membership.Create();
                Assert.True(0 < membership.ID);

                membership.Find();
                Assert.True(membership.Exists());
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
        public void FindByNameFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (sender, e) =>
                {
                    var actual = new Membership(new MembershipEntity()
                    {
                        Name = e.Name, Password = null,
                    })
                                 .Find();
                    Assert.True(0 < actual.ID);
                };
                membership.Create();
                membership.Find();
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
        public void UpdateFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                })
                             .Create();
                membership.Found += (sender, e) =>
                {
                    e.Enabled = false;
                    var updated = new Membership(e);
                    updated.Found += (_, __) => Assert.False(__.Enabled);
                    updated.Update();
                    updated.Find();
                };
                membership.Find();
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
        public void CreateFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = @"",
                });
                membership.Found += (_, __) =>
                {
                    Assert.Equal(membership.ID, __.ID);
                };
                membership.Create();
                Assert.True(0 < membership.ID);

                Assert.True(membership.Exists());
                membership.Find();
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
        public void DeleteFact()
        {
            var membership = new Membership(new MembershipEntity()
            {
                Name = @"name", Password = @"password", Enabled = true,
            }).Create();

            membership = membership.Delete();
            Assert.False(0 < membership.ID);
        }
        public void CreateFact()
        {
            var membership = default(Membership);
            var user       = default(User);

            try
            {
                user = new User(new UserEntity());
                user.Create();

                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name,
                });
                membership.Users.Add(user.ID);
                membership.Create();
                membership.Find();

                user.Find();

                Assert.Equal(membership.ID, user.MembershipID);
                Assert.Contains(user.ID, membership.Users);
            }
            finally
            {
                if (user != null)
                {
                    user.Delete();
                }
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }
        public void ExistsFact()
        {
            var membership = default(Membership);

            try
            {
                var name = new Random().Next().ToString(CultureInfo.InvariantCulture);
                membership = new Membership(new MembershipEntity()
                {
                    Name = name, Password = null,
                });
                membership.Create();

                Assert.True(Membership.Exists(name));
                Assert.True(membership.Exists());
            }
            finally
            {
                if (membership != null)
                {
                    membership.Delete();
                }
            }
        }