Example #1
0
        public void TheNextAmountShouldBeGreaterThanOne()
        {
            using (mocks.Record())
                listBuilderImpl.Expect(x => x.Capacity).Return(10);

            ListBuilderExtensions.TheNext(listBuilderImpl, 0);
        }
        public void TheNextAmountShouldBeGreaterThanOne()
        {
            listBuilderImpl.Capacity.Returns(10);

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

            Assert.Throws <ArgumentException>(() =>
            {
                ListBuilderExtensions.TheNext(listBuilderImpl, 0);
            });
        }
        public void ShouldOnlyAddTheDeclarationIfTheRangeIsValid()
        {
            IDeclarationQueue <MyClass> declarationQueue = Substitute.For <IDeclarationQueue <MyClass> >();
            RangeDeclaration <MyClass>  rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 0, 9);

            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            listBuilderImpl.CreateObjectBuilder().Returns((IObjectBuilder <MyClass>)null);
            declarationQueue.GetLastItem().Returns(rangeDeclaration);
            listBuilderImpl.Declarations.Returns(declarationQueue);
            listBuilderImpl.AddDeclaration(Arg.Any <RangeDeclaration <MyClass> >()).Throws(new BuilderException(""));
            Assert.Throws <BuilderException>(
                () => ListBuilderExtensions.TheNext(listBuilderImpl, 30)
                );
        }
        public void TheNextShouldReturnRangeDeclaration()
        {
            IDeclarationQueue <MyClass> declarationQueue = Substitute.For <IDeclarationQueue <MyClass> >();
            RangeDeclaration <MyClass>  rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 0, 9);

            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            listBuilderImpl.CreateObjectBuilder().Returns((IObjectBuilder <MyClass>)null);
            declarationQueue.GetLastItem().Returns(rangeDeclaration);
            listBuilderImpl.Declarations.Returns(declarationQueue);
            listBuilderImpl.AddDeclaration(Arg.Any <RangeDeclaration <MyClass> >()).Returns((IDeclaration <MyClass>)null);

            listBuilderImpl.BuilderSettings.Returns(new BuilderSettings());
            var andTheNextDeclaration = (RangeDeclaration <MyClass>)ListBuilderExtensions.TheNext(listBuilderImpl, 10);

            Assert.That(andTheNextDeclaration.Start, Is.EqualTo(10));
            Assert.That(andTheNextDeclaration.End, Is.EqualTo(19));
        }
Example #6
0
        public void ShouldOnlyAddTheDeclarationIfTheRangeIsValid()
        {
            IDeclarationQueue <MyClass> declarationQueue = mocks.StrictMock <IDeclarationQueue <MyClass> >();
            RangeDeclaration <MyClass>  rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 0, 9);

            using (mocks.Record())
            {
                listBuilderImpl.Expect(x => x.CreateObjectBuilder()).Return(null);
                declarationQueue.Expect(x => x.GetLastItem()).Return(rangeDeclaration);
                listBuilderImpl.Expect(x => x.Declarations).Return(declarationQueue);
                listBuilderImpl.Expect(x => x.AddDeclaration(Arg <RangeDeclaration <MyClass> > .Is.TypeOf)).Throw(new BuilderException(""));
            }

            using (mocks.Playback())
            {
                Assert.Throws <BuilderException>(
                    () => ListBuilderExtensions.TheNext(listBuilderImpl, 30)
                    );
            }
        }
Example #7
0
        public void TheNextShouldReturnRangeDeclaration()
        {
            IDeclarationQueue <MyClass> declarationQueue = mocks.StrictMock <IDeclarationQueue <MyClass> >();
            RangeDeclaration <MyClass>  rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 0, 9);

            using (mocks.Record())
            {
                listBuilderImpl.Expect(x => x.CreateObjectBuilder()).Return(null);
                declarationQueue.Expect(x => x.GetLastItem()).Return(rangeDeclaration);
                listBuilderImpl.Expect(x => x.Declarations).Return(declarationQueue);
                listBuilderImpl.Expect(x => x.AddDeclaration(Arg <RangeDeclaration <MyClass> > .Is.TypeOf)).Return(null);
            }

            using (mocks.Playback())
            {
                var andTheNextDeclaration = (RangeDeclaration <MyClass>)ListBuilderExtensions.TheNext(listBuilderImpl, 10);

                Assert.That(andTheNextDeclaration.Start, Is.EqualTo(10));
                Assert.That(andTheNextDeclaration.End, Is.EqualTo(19));
            }
        }