Exemplo n.º 1
0
        public static IEnumerable Subsets(SqlInt32 cardinal)
        {
            if (cardinal.IsNull)
            {
                yield break;
            }

            var c = new Subset(cardinal.Value);

            for (var success = c.First(); success; success = c.Next())
            {
                yield return(c);
            }
        }
Exemplo n.º 2
0
        public void Next1()
        {
            var subSet      = new Subset(1, 10, 5);
            var firstSubSet = subSet.Get();

            Assert.AreEqual(new int[] { 1, 2, 3, 4, 5 }, firstSubSet);
            var count = 1;

            while (subSet.Next())
            {
                count++;
            }
            Assert.AreEqual(252, count);
        }
Exemplo n.º 3
0
        public void Next2()
        {
            var subSet      = new Subset(1, 20, 3);
            var firstSubSet = subSet.Get();

            Assert.AreEqual(new int[] { 1, 2, 3 }, firstSubSet);
            var count = 1;

            while (subSet.Next())
            {
                count++;
            }
            Assert.AreEqual(1140, count);
        }
Exemplo n.º 4
0
        public void Next3()
        {
            var count = 0;

            for (var i = 0; i <= 10; i++)
            {
                var subSet = new Subset(1, 10, i);
                count++;
                while (subSet.Next())
                {
                    count++;
                }
            }
            Assert.AreEqual(1024, count);
        }