public void ShouldBeAbleToUseThePrevious()
        {
            IDeclarationQueue <MyClass> declarationQueue = Substitute.For <IDeclarationQueue <MyClass> >();
            RangeDeclaration <MyClass>  rangeDeclaration = new RangeDeclaration <MyClass>(listBuilderImpl, null, 10, 19);

            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 thePreviousDeclaration = (RangeDeclaration <MyClass>)ListBuilderExtensions.ThePrevious(listBuilderImpl, 10);

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

            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 thePreviousDeclaration = (RangeDeclaration <MyClass>)ListBuilderExtensions.ThePrevious(listBuilderImpl, 10);

                Assert.That(thePreviousDeclaration.Start, Is.EqualTo(0));
                Assert.That(thePreviousDeclaration.End, Is.EqualTo(9));
            }
        }