Ejemplo n.º 1
0
        public void Set_NullTemplate_Empty()
        {
            // Act
            _tpl.Add(VariableName, (ITemplate)null);

            // Assert
            Assert.AreEqual("", _tpl.Get());
        }
Ejemplo n.º 2
0
        public IActionResult RegisterTemplate([FromBody] Template template)
        {
            Utility.Message message = _templateContext.Add(template);
            string          context = message == Utility.Message.Success ? "success" : "error";

            return(new JsonResult(new { Message = Utility.GetMessage(message), context = context }));
        }
Ejemplo n.º 3
0
        public void Add_NullVariableName_ArgumentNullException()
        {
            // Act
            var ex = Assert.Throws <ArgumentNullException>(() => _tpl.Add(null, "test"));

            // Assert
            Assert.AreEqual("Value cannot be null. (Parameter 'variableName')", ex.Message);
        }
        private static void TestTemplate(ITemplate tpl, ITemplate masterTemplate, ITemplate testTemplate, ITemplate masterTestTemplate)
        {
            masterTemplate.Set("Title", "Hello world!!!");

            tpl.Set("ItemTitle", "Item1");

            tpl.Add("var1", 15.5m);
            tpl.Add("var1", (long)16);
            tpl.Add("var1", 17);
            tpl.Add("var1", 18.16);
            tpl.Add("var1", new object());

            tpl.Set("var2", 15.5m)
            .Set("var3", (long)16)
            .Set("var4", 17)
            .Set("var5", 18.16)
            .Set("var6", new object());

            Assert.AreEqual(testTemplate.Get(), tpl.Get());

            masterTemplate.Add("Items", tpl.GetAndRoll());

            tpl.Set("ItemTitle", "Item2");

            tpl.Add("var1", 16.5m)
            .Add("var1", (long)255)
            .Add("var1", 300)
            .Add("var1", 26.15)
            .Add("var1", new object());

            tpl.Set("var2", 10.5m);
            tpl.Set("var3", (long)1);
            tpl.Set("var4", 3);
            tpl.Set("var5", 4.1233);
            tpl.Set("var6", new object());

            tpl.Set("NotFoundItem", (ITemplate)null);

            masterTemplate.Add("Items", tpl);
            masterTemplate.Set("FromTemplateNull", (ITemplate)null);
            masterTemplate.Set("FromTemplateNotNull", Template.FromString("test"));

            Assert.AreEqual(masterTestTemplate.Get(), masterTemplate.Get());
        }
Ejemplo n.º 5
0
		private static void TestTemplate(ITemplate tpl, ITemplate masterTemplate, ITemplate testTemplate, ITemplate masterTestTemplate)
		{
			masterTemplate.Set("Title", "Hello world!!!");

			tpl.Set("ItemTitle", "Item1");

			tpl.Add("var1", 15.5m);
			tpl.Add("var1", (long)16);
			tpl.Add("var1", 17);
			tpl.Add("var1", 18.16);
			tpl.Add("var1", new object());

			tpl.Set("var2", 15.5m)
				.Set("var3", (long)16)
				.Set("var4", 17)
				.Set("var5", 18.16)
				.Set("var6", new object());

			Assert.AreEqual(testTemplate.Get(), tpl.Get());

			masterTemplate.Add("Items", tpl.GetAndRoll());

			tpl.Set("ItemTitle", "Item2");

			tpl.Add("var1", 16.5m)
				.Add("var1", (long)255)
				.Add("var1", 300)
				.Add("var1", 26.15)
				.Add("var1", new object());

			tpl.Set("var2", 10.5m);
			tpl.Set("var3", (long)1);
			tpl.Set("var4", 3);
			tpl.Set("var5", 4.1233);
			tpl.Set("var6", new object());

			tpl.Set("NotFoundItem", (ITemplate)null);

			masterTemplate.Add("Items", tpl);

			Assert.AreEqual(masterTestTemplate.Get(), masterTemplate.Get());
		}
        public void ShouldRenderClassProperty()
        {
            _target.Add(new Dictionary <string, object>
            {
                { "user", new User() }
            });

            var result = _target.Render();

            result.Should().NotBeNullOrEmpty();
            result.ShouldBeEquivalentTo("Hello, John Doe");
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Add value to set template variable value with text from template (all occurrences will be replaced on Get method execute) allows setting multiple values to template variable
 /// </summary>
 /// <param name="tpl">The TPL.</param>
 /// <param name="variableName">Variable name</param>
 /// <param name="template">Value to set</param>
 /// <returns></returns>
 public static ITemplate Add(this ITemplate tpl, string variableName, ITemplate template)
 {
     return(tpl.Add(variableName, template?.Get()));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Add value to set template variable value (all occurrences will be replaced on Get method execute) allows setting multiple values to template variable
 /// </summary>
 /// <param name="tpl">The TPL.</param>
 /// <param name="variableName">Variable name</param>
 /// <param name="value">Value to set</param>
 /// <returns></returns>
 public static ITemplate Add(this ITemplate tpl, string variableName, long value)
 {
     return(tpl.Add(variableName, value.ToString(CultureInfo.InvariantCulture)));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Add value to set template variable value (all occurrences will be replaced on Get method execute) allows setting multiple values to template variable
 /// </summary>
 /// <param name="tpl">The TPL.</param>
 /// <param name="variableName">Variable name</param>
 /// <param name="value">Value to set</param>
 /// <returns></returns>
 public static ITemplate Add(this ITemplate tpl, string variableName, object?value)
 {
     return(tpl.Add(variableName, value?.ToString()));
 }
Ejemplo n.º 10
0
 public bool Add(E_Model.Template model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 11
0
 public async Task PostAsync([FromBody] Template t)
 {
     await _inter.Add(t);
 }