public void PassesTheSparkDescriptorIncludingTheTemplateNameToTheView()
        {
            const string viewName = "myView";
            var sparkViewEngine = MockRepository.GenerateStub<ISparkViewEngine>().StubCreateInstance();
            var resolver = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            resolver.Create(viewName,null);

            var sparkViewDescriptor = (SparkViewDescriptor)sparkViewEngine.GetArgumentsForSingleCall(x => x.CreateInstance(null));
            Assert.That(sparkViewDescriptor.Templates.FirstOrDefault(), Is.EqualTo(viewName));
        }
        public void UsesTheSparkEngineToCreateAView()
        {
            var expectedSparkView = new TestSparkResourceView();
            var sparkViewEngine = MockRepository.GenerateStub<ISparkViewEngine>()
                .StubCreateInstance(expectedSparkView);
            sparkViewEngine.StubCreateInstance(expectedSparkView);
            var resolver = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            ISparkView resolvedView = resolver.Create(null, null);

            Assert.That(resolvedView, Is.EqualTo(expectedSparkView));
        }
Пример #3
0
        public void PassesTheSparkDescriptorIncludingTheTemplateNameToTheView()
        {
            const string viewName        = "myView";
            var          sparkViewEngine = MockRepository.GenerateStub <ISparkViewEngine>().StubCreateInstance();
            var          resolver        = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            resolver.Create(viewName, null);

            var sparkViewDescriptor = (SparkViewDescriptor)sparkViewEngine.GetArgumentsForSingleCall(x => x.CreateInstance(null));

            Assert.That(sparkViewDescriptor.Templates.FirstOrDefault(), Is.EqualTo(viewName));
        }
Пример #4
0
        public void UsesTheSparkEngineToCreateAView()
        {
            var expectedSparkView = new TestSparkResourceView();
            var sparkViewEngine   = MockRepository.GenerateStub <ISparkViewEngine>()
                                    .StubCreateInstance(expectedSparkView);

            sparkViewEngine.StubCreateInstance(expectedSparkView);
            var resolver = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            ISparkView resolvedView = resolver.Create(null, null);

            Assert.That(resolvedView, Is.EqualTo(expectedSparkView));
        }
        public void EnhancesTheViewWithTheViewData()
        {
            var expectedSparkView = new TestSparkResourceView();
            var sparkViewEngine = MockRepository.GenerateStub<ISparkViewEngine>()
                .StubCreateInstance(expectedSparkView);
            sparkViewEngine.StubCreateInstance(expectedSparkView);
            var resolver = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            object viewData = new object();
            SparkResourceView resolvedView = (SparkResourceView) resolver.Create(null, viewData);

            Assert.That(resolvedView.ViewData, Is.Not.Null);
            Assert.That(resolvedView.ViewData.Eval("Resource"), Is.EqualTo(viewData));
        }
Пример #6
0
        public void EnhancesTheViewWithTheViewData()
        {
            var expectedSparkView = new TestSparkResourceView();
            var sparkViewEngine   = MockRepository.GenerateStub <ISparkViewEngine>()
                                    .StubCreateInstance(expectedSparkView);

            sparkViewEngine.StubCreateInstance(expectedSparkView);
            var resolver = new SparkViewResolverBuilder().With(sparkViewEngine).Build();

            object            viewData     = new object();
            SparkResourceView resolvedView = (SparkResourceView)resolver.Create(null, viewData);

            Assert.That(resolvedView.ViewData, Is.Not.Null);
            Assert.That(resolvedView.ViewData.Eval("Resource"), Is.EqualTo(viewData));
        }