Exemplo n.º 1
0
        public void TestGetSingle()
        {
            var x = new ConsistentHash();

            x.Add("abcdefg");

            Quick.Check <string>(s =>
            {
                var y = x.Get(s);
                return(y == "abcdefg");
            });
        }
Exemplo n.º 2
0
        public void TestGetMultipleQuick()
        {
            var x = new ConsistentHash();

            x.Add("abcdefg");
            x.Add("hijklmn");
            x.Add("opqrstu");

            Quick.Check <string>(s =>
            {
                var y = x.Get(s);
                return(y == "abcdefg" || y == "hijklmn" || y == "opqrstu");
            });
        }
Exemplo n.º 3
0
        public void TestGetNMoreQuick()
        {
            var x = new ConsistentHash();

            x.Add("abcdefg");
            x.Add("hijklmn");
            x.Add("opqrstu");

            Quick.Check <string>(s =>
            {
                var members = x.GetN(s, 5).ToArray();

                if (members.Length != 3)
                {
                    return(false);
                }

                var set = new HashSet <string>();

                foreach (var member in members)
                {
                    if (set.Contains(member))
                    {
                        return(false);
                    }

                    set.Add(member);

                    if (member != "abcdefg" && member != "hijklmn" && member != "opqrstu")
                    {
                        return(false);
                    }
                }

                return(true);
            });
        }