public void RandomAmountMustBeOneOrGreater()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         ListBuilderExtensions.Random(listBuilderImpl, 0);
     });
 }
Exemplo n.º 2
0
        public void RandomAmountShouldBeLessThanListCapacity()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            ListBuilderExtensions.Random(listBuilderImpl, 11);
        }
        public void RandomAmountShouldBeLessThanListCapacity()
        {
            listBuilderImpl.Capacity.Returns(10);

            Assert.Throws <ArgumentException>(() =>
            {
                ListBuilderExtensions.Random(listBuilderImpl, 11);
            });
        }
        public void RandomAmountShouldBeLessThanListCapacity()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            Assert.Throws <ArgumentException>(() =>
            {
                ListBuilderExtensions.Random(listBuilderImpl, 11);
            });
        }
        public void RandomShouldReturnRandomDeclarationOfRangeOfWholeList()
        {
            const int amount = 5;
            const int end    = listSize;

            var randomDeclaration = new RandomDeclaration <MyClass>(listBuilderImpl, null, null, amount, 0, end);

            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            listBuilderImpl.Capacity.Returns(listSize);
            listBuilderImpl.AddDeclaration(Arg.Is <RandomDeclaration <MyClass> >(y => y.Start == 0 && y.End == end)).Returns(randomDeclaration);

            IDeclaration <MyClass> declaration;

            declaration = (IDeclaration <MyClass>)ListBuilderExtensions.Random(listBuilderImpl, amount);

            Assert.That(declaration.Start, Is.EqualTo(0));
            Assert.That(declaration.End, Is.EqualTo(end));
        }
        public void RandomCanReturnDeclarationForASectionOfTheList()
        {
            const int amount = 5;
            const int start  = 10;
            const int end    = 20;

            var randomDeclaration = new RandomDeclaration <MyClass>(listBuilderImpl, null, null, amount, start, end);


            listBuilderImpl.Capacity.Returns(listSize);
            listBuilderImpl.AddDeclaration(Arg.Is <RandomDeclaration <MyClass> >(y => y.Start == start && y.End == end)).Returns(randomDeclaration);



            var declaration = (IDeclaration <MyClass>)ListBuilderExtensions.Random(listBuilderImpl, amount, start, end);

            Assert.That(declaration.Start, Is.EqualTo(start));
            Assert.That(declaration.End, Is.EqualTo(end));
        }
        public void RandomCanReturnDeclarationForASectionOfTheList()
        {
            const int amount = 5;
            const int start  = 10;
            const int end    = 20;

            var randomDeclaration = new RandomDeclaration <MyClass>(listBuilderImpl, null, null, amount, start, end);

            using (mocks.Record())
            {
                listBuilderImpl.Expect(x => x.Capacity).Return(listSize).Repeat.Any();
                listBuilderImpl.Expect(x => x.AddDeclaration(Arg <RandomDeclaration <MyClass> > .Matches(y => y.Start == start && y.End == end))).Return(randomDeclaration);
            }


            var declaration = (IDeclaration <MyClass>)ListBuilderExtensions.Random(listBuilderImpl, amount, start, end);

            Assert.That(declaration.Start, Is.EqualTo(start));
            Assert.That(declaration.End, Is.EqualTo(end));
        }
Exemplo n.º 8
0
        public void RandomShouldReturnRandomDeclarationOfRangeOfWholeList()
        {
            const int amount = 5;
            const int end    = listSize;

            var randomDeclaration = new RandomDeclaration <MyClass>(listBuilderImpl, null, null, amount, 0, end);

            using (mocks.Record())
            {
                listBuilderImpl.Expect(x => x.Capacity).Return(listSize).Repeat.Any();
                listBuilderImpl.Expect(x => x.AddDeclaration(Arg <RandomDeclaration <MyClass> > .Matches(y => y.Start == 0 && y.End == end))).Return(randomDeclaration);
            }

            IDeclaration <MyClass> declaration;

            using (mocks.Playback())
            {
                declaration = (IDeclaration <MyClass>)ListBuilderExtensions.Random(listBuilderImpl, amount);
            }

            Assert.That(declaration.Start, Is.EqualTo(0));
            Assert.That(declaration.End, Is.EqualTo(end));
        }
Exemplo n.º 9
0
 public void RandomAmountMustBeOneOrGreater()
 {
     ListBuilderExtensions.Random(listBuilderImpl, 0);
 }