Scalien.Users.IsConsistent C# (CSharp) Метод

IsConsistent() публичный Метод

public IsConsistent ( ) : bool
Результат bool
        public bool IsConsistent()
        {
            TestUser user;
            TestUserInfo cmpinfo;
            byte[] row;

            // byte array?
            foreach (string key in table.GetKeyIterator(new StringRangeParams()))
            {
                user = GetUser(key);

                row = tableByNick.Get(System.Text.Encoding.UTF8.GetBytes(user.info.Nick + "|" + user.info.id.ToString()));
                if (row == null) return false;
                cmpinfo = Utils.JsonDeserialize<TestUserInfo>(row);
                if (user.info != cmpinfo)
                    return false;

                row = tableByBirth.Get(System.Text.Encoding.UTF8.GetBytes(user.info.DateOfBirth + "|" + user.info.id.ToString()));
                if (row == null) return false;
                cmpinfo = Utils.JsonDeserialize<TestUserInfo>(row);
                if (user.info != cmpinfo)
                    return false;

                row = tableByLastLogin.Get(System.Text.Encoding.UTF8.GetBytes(user.info.LastLogin + "|" + user.info.id.ToString()));
                if (row == null) return false;
                cmpinfo = Utils.JsonDeserialize<TestUserInfo>(row);
                if (user.info != cmpinfo)
                    return false;
            }

            return true;
        }

Usage Example

Пример #1
0
        //[TestMethod]
        public void ShortTest_1000_Threads()
        {
            int init_users = 1000;
            int threadnum = 1000;

            Users usr = new Users(Utils.GetConfigNodes());
            usr.EmptyAll();
            usr.InsertUsers(init_users);

            Utils.TestThreadConf threadConf = new Utils.TestThreadConf();
            threadConf.param = 500;

            Thread[] threads = new Thread[threadnum];
            for (int i = 0; i < threadnum; i++)
            {
                threads[i] = new Thread(new ParameterizedThreadStart(TestWorker));
                threads[i].Start(threadConf);
            }

            for (int i = 0; i < threadnum; i++)
            {
                threads[i].Join();
            }

            if (threadConf.exceptionsCatched.Count > 0)
                Assert.Fail("Exceptions catched in threads", threadConf);

            Console.WriteLine("Checking consistency");

            Assert.IsTrue(usr.IsConsistent());
        }
All Usage Examples Of Scalien.Users::IsConsistent