Esempio n. 1
0
        public void BindingProviderIsCalledUsingTheCorrectBindingRequest()
        {
            var bindingProvider = MockRepository.GenerateMock<IBindingProvider>();
            var syntaxProvider = MockRepository.GenerateStub<ISparkSyntaxProvider>();
            var viewPath = Path.Combine("Account", "index.spark");
            var folder = new StubViewFolder { Path = viewPath, LastModified = 4 };

            bindingProvider.Expect(x => x.GetBindings(null))
                .IgnoreArguments()
                .Return(new Binding[0])
                .Callback<BindingRequest>(x => x.ViewFolder == folder && x.ViewPath == viewPath);

            syntaxProvider.Stub(x => x.GetChunks(null, null))
                .IgnoreArguments()
                .Return(new List<Chunk>());
            var viewLoader = new ViewLoader
            {
                ViewFolder = folder,
                SyntaxProvider = syntaxProvider,
                BindingProvider = bindingProvider
            };
            viewLoader.Load(viewPath);

            bindingProvider.VerifyAllExpectations();
        }
Esempio n. 2
0
        public void BindingProviderIsCalledUsingTheCorrectBindingRequest()
        {
            var bindingProvider = MockRepository.GenerateMock <IBindingProvider>();
            var syntaxProvider  = MockRepository.GenerateStub <ISparkSyntaxProvider>();
            var viewPath        = Path.Combine("Account", "index.spark");
            var folder          = new StubViewFolder {
                Path = viewPath, LastModified = 4
            };

            bindingProvider.Expect(x => x.GetBindings(null))
            .IgnoreArguments()
            .Return(new Binding[0])
            .Callback <BindingRequest>(x => x.ViewFolder == folder && x.ViewPath == viewPath);

            syntaxProvider.Stub(x => x.GetChunks(null, null))
            .IgnoreArguments()
            .Return(new List <Chunk>());
            var viewLoader = new ViewLoader
            {
                ViewFolder      = folder,
                SyntaxProvider  = syntaxProvider,
                BindingProvider = bindingProvider
            };

            viewLoader.Load(viewPath);

            bindingProvider.VerifyAllExpectations();
        }
Esempio n. 3
0
        public void ExpiresWhenFilesChange()
        {
            var viewFolder = new StubViewFolder { Path = Path.Combine("home", "changing.spark"), LastModified = 4 };

            var viewLoader = new ViewLoader
                             {
                                 ViewFolder = viewFolder,
                                 SyntaxProvider = MockRepository.GenerateStub<ISparkSyntaxProvider>()
                             };
            viewLoader.SyntaxProvider
                .Expect(x => x.GetChunks(null, null))
                .IgnoreArguments()
                .Return(new Chunk[0]);

            viewLoader.Load(Path.Combine("home", "changing.spark"));

            Assert.That(viewLoader.IsCurrent());

            viewFolder.LastModified = 7;
            Assert.That(!viewLoader.IsCurrent());
        }
Esempio n. 4
0
        public void ExpiresWhenFilesChange()
        {
            var viewFolder = new StubViewFolder {
                Path = "home\\changing.spark", LastModified = 4
            };

            var viewLoader = new ViewLoader
            {
                ViewFolder     = viewFolder,
                SyntaxProvider = MockRepository.GenerateStub <ISparkSyntaxProvider>()
            };

            viewLoader.SyntaxProvider
            .Expect(x => x.GetChunks(null, null))
            .IgnoreArguments()
            .Return(new Chunk[0]);

            viewLoader.Load("home\\changing.spark");

            Assert.That(viewLoader.IsCurrent());

            viewFolder.LastModified = 7;
            Assert.That(!viewLoader.IsCurrent());
        }