//Check that create a VDB call will return a response.
        public void CreateTemplateTest()
        {
            // Create and valiate a session
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            // Trust all certificates
            System.Net.ServicePointManager.ServerCertificateValidationCallback =
                ((sender, certificate, chain, sslPolicyErrors) => true);

            // Get a cookie + Authenticate
            Session.CreateSession(System.Environment.GetEnvironmentVariable("DELPHIX_USER"), System.Environment.GetEnvironmentVariable("DELPHIX_PASSWORD"), System.Environment.GetEnvironmentVariable("DELPHIX_URL"));
            string cookie = Session.jSessionId.Value;


            //Create helpers
            TemplateService        tempService = new TemplateService();
            DatabaseService        dbHelp      = new DatabaseService();
            DelphixDatabase        vdb         = new DelphixDatabase();
            List <DelphixDatabase> allDbs      = new List <DelphixDatabase>();

            allDbs = dbHelp.GetDatabases();
            DelphixDatabase aVdb = allDbs.First();

            allDbs.Clear();
            allDbs.Add(aVdb);
            //Create a test template
            DelphixResponse response = tempService.CreateTemplate("testTemp", allDbs);
        }
Esempio n. 2
0
        private void CreateTemplateAndSetInCache(string key_, string template_)
        {
            TemplateService service  = new TemplateService();
            ITemplate       template = service.CreateTemplate(template_, null, null);

            DependencyManager.CachingService.Set <ITemplate>(key_, template);
        }
Esempio n. 3
0
        public PackageId CreateTemplate(DocumentPackage template)
        {
            PackageId templateId = templateService.CreateTemplate(new DocumentPackageConverter(template).ToAPIPackage());

            foreach (Document document in template.Documents)
            {
                UploadDocument(document, templateId);
            }

            return(templateId);
        }
        public void TemplateService_CanParseSimpleTemplate_WithCorrectBaseTypeFromModel()
        {
            using (var service = new TemplateService())
            {
                const string template = "<h1>Hello @Model.Forename</h1>";

                var model = new Person {
                    Forename = "Matt"
                };
                var templateInstance = service.CreateTemplate(template, null, model);

                Assert.NotNull(templateInstance as ITemplate <Person>, "Template is not derived from the correct base type");
            }
        }
        public void TemplateService_CanParseSimpleTemplate_WithNonGenericBaseType()
        {
            var config = new TemplateServiceConfiguration {
                BaseTemplateType = typeof(NonGenericTemplateBase)
            };

            using (var service = new TemplateService(config))
            {
                const string template = "<h1>@GetHelloWorldText()</h1>";

                var templateInstance = service.CreateTemplate(template, null, null);

                Assert.NotNull(templateInstance as NonGenericTemplateBase, "Template is not derived from the correct base type");
            }
        }
        public ActionResult Create(TemplateSimple model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new TemplateService();
            int id      = service.CreateTemplate(model);

            service.SeedNameProperty(id);

            if (id != 0)
            {
                TempData["SaveResult"] = "Add Properties.";
                return(RedirectToAction("Create", "TemplateProperty", new { templateId = id }));
            }
            ;

            ModelState.AddModelError("", "Template could not be created.");

            return(View(model));
        }
Esempio n. 7
0
 private void CreateTemplateAndSetInCache(string key_, string template_)
 {
     TemplateService service = new TemplateService();
     ITemplate template = service.CreateTemplate(template_, null, null);
     DependencyManager.CachingService.Set<ITemplate>(key_, template);
 }