public void SectionStartCannotEqualEnd()
        {
            listBuilderImpl.Capacity.Returns(10);

            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 5, 5));
        }
 public void SectionStartMustBeGreaterThanZero()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         ListBuilderExtensions.Section(listBuilderImpl, -1, 10);
     });
 }
        public void SectionEndMustBeLessThanCapacity()
        {
            listBuilderImpl.Capacity.Returns(10);

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

            ListBuilderExtensions.Section(listBuilderImpl, 0, 9);
        }
        public void SectionStartMustBeLessThanEnd()
        {
            listBuilderImpl.Capacity.Returns(10);

            // TODO FIX
            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 6, 5));
        }
        public void SectionEndMustBeGreaterThanOne()
        {
            listBuilderImpl.Capacity.Returns(10);

            // TODO FIX
            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 0, 0));
        }
        public void SectionEndMustBeLessThanCapacity()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 9, 10));
        }
        public void SectionStartMustBeLessThanCapacity()
        {
            listBuilderImpl.Capacity.Returns(10);

            var ex = Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 10, 10));

            Assert.That(ex.Message.Contains("start"));
        }
        public void SectionCanCoverWholeList()
        {
            listBuilderImpl.Capacity.Returns(10);
            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            listBuilderImpl.AddDeclaration(Arg.Any <IDeclaration <MyClass> >())
            .Returns(new MyDeclaration <MyClass>());

            ListBuilderExtensions.Section(listBuilderImpl, 0, 9);
        }
        public void SectionStartMustBeLessThanCapacity()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            var ex = Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 10, 10));

            Assert.That(ex.Message.Contains("start"));
        }
        public void SectionStartCannotEqualEnd()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            // TODO FIX
            #if !SILVERLIGHT
            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 5, 5));
            #endif
        }
        public void SectionEndMustBeGreaterThanOne()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            // TODO FIX
            #if !SILVERLIGHT
            Assert.Throws <ArgumentException>(
                () => ListBuilderExtensions.Section(listBuilderImpl, 0, 0));
            #endif
        }
        public void ShouldBeAbleToUseSection()
        {
            var rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 10, 19);

            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            listBuilderImpl.Capacity.Returns(20);
            listBuilderImpl.CreateObjectBuilder().Returns((IObjectBuilder <MyClass>)null);
            listBuilderImpl.AddDeclaration(Arg.Is <RangeDeclaration <MyClass> >(y => y.Start == 10 && y.End == 19)).Returns(rangeDeclaration);

            var whereSection = (RangeDeclaration <MyClass>)ListBuilderExtensions.Section(listBuilderImpl, 10, 19);

            Assert.That(whereSection.Start, Is.EqualTo(10));
            Assert.That(whereSection.End, Is.EqualTo(19));
        }
Example #14
0
        public void ShouldBeAbleToUseSection()
        {
            var rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 10, 19);

            using (mocks.Record())
            {
                listBuilderImpl.Expect(x => x.Capacity).Return(20);
                listBuilderImpl.Expect(x => x.CreateObjectBuilder()).Return(null);
                listBuilderImpl.Expect(x => x.AddDeclaration(Arg <RangeDeclaration <MyClass> > .Matches(y => y.Start == 10 && y.End == 19))).Return(rangeDeclaration);
            }

            using (mocks.Playback())
            {
                var whereSection = (RangeDeclaration <MyClass>)ListBuilderExtensions.Section(listBuilderImpl, 10, 19);

                Assert.That(whereSection.Start, Is.EqualTo(10));
                Assert.That(whereSection.End, Is.EqualTo(19));
            }
        }
Example #15
0
 public void SectionStartMustBeGreaterThanZero()
 {
     ListBuilderExtensions.Section(listBuilderImpl, -1, 10);
 }