Exemple #1
0
        protected override void beforeEach()
        {
            _root = AppDomain.CurrentDomain.BaseDirectory;

            _templateRegistry = new TemplateRegistry <IRazorTemplate>(new[]
            {
                new Template(Path.Combine(_root, "Views", "Home", "ModelAView.cshtml"), _root, TemplateConstants.HostOrigin),
                new Template(Path.Combine(_root, "Views", "Home", "_partial1.cshtml"), _root, TemplateConstants.HostOrigin),
                new Template(Path.Combine(_root, "Views", "Home", "ModelBView.cshtml"), _root, TemplateConstants.HostOrigin),
                new Template(Path.Combine(_root, "Views", "Home", "_partial2.cshtml"), _root, TemplateConstants.HostOrigin),
                new Template(Path.Combine(_root, "Views", "Home", "ModelCView.cshtml"), _root, TemplateConstants.HostOrigin),
                new Template(Path.Combine(_root, "Views", "Home", "_partial3.cshtml"), _root, TemplateConstants.HostOrigin)
            });

            var templates = _templateRegistry.ToList();

            templates[0].Descriptor = new ViewDescriptor <IRazorTemplate>(templates[0])
            {
                ViewModel = typeof(ModelA)
            };
            templates[2].Descriptor = new ViewDescriptor <IRazorTemplate>(templates[2])
            {
                ViewModel = typeof(ModelB)
            };
            templates[4].Descriptor = new ViewDescriptor <IRazorTemplate>(templates[4])
            {
                ViewModel = typeof(ModelC)
            };

            Services.Inject(_templateRegistry);
        }