public void TestFindUsersInRoleQueryCount()
        {
            var roleProvider = new CustomRoleProvider();
            var queryCount   = new EntityFrameworkActivityLogger();

            using (var usersContext = new ApplicationDbContext())
                using (new WithInterception(queryCount))
                {
                    roleProvider.FindUsersInRole(usersContext, testRoleX.Name, "");

                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::FindUsersInRole exceeded the expected number.");

                    queryCount.Reset();

                    roleProvider.FindUsersInRole(usersContext, testRoleX.Name, testUserA.UserName);

                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::FindUsersInRole exceeded the expected number.");
                }
        }
        public void TestGetRolesForUserQueryCount()
        {
            var roleProvider = new CustomRoleProvider();
            var queryCount   = new EntityFrameworkActivityLogger();

            using (var usersContext = new ApplicationDbContext())
                using (new WithInterception(queryCount))
                {
                    roleProvider.GetRolesForUser(usersContext, testUserA.UserName);

                    // We expect 1 query to get the user, and 1 query to get the role names
                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::GetRolesForUser exceeded the expected number.");

                    queryCount.Reset();

                    roleProvider.GetRolesForUser(usersContext, testUserB.UserName);

                    // The query count should be the same, regardless of the number of roles a user is a member of
                    Assert.AreEqual(2, queryCount.TotalExecutedCount,
                                    "The query count for CustomRoleProvider::GetRolesForUser exceeded the expected number.");
                }
        }