public void SetTemplateVarTableTest()
        {
            var validator = new TemplateValidator(new MockRandomTableService(), new MockTemplateService());

            var testVal = @"[var:{ ""name"":""race"",""display"":true,""value"":""tbl:race""}]";

            var field = new TemplateField
            {
                Sort      = 1,
                Value     = testVal,
                FieldType = TemplateFieldType.Variable
            };

            var(error, result) = validator.SetVariableField(field).Result;

            var json = JsonConvert.DeserializeObject <TemplateVar>(result.TemplateJson);

            var tblField = JsonConvert.DeserializeObject <TemplateField>(json.TemplateObjectJson);

            var tbl = JsonConvert.DeserializeObject <TemplateTbl>(tblField.TemplateJson);

            Assert.AreEqual(field.VariableName, "race", $"Variable name field is incorrect: {field.VariableName}");
            Assert.AreEqual(ValidationError.None, error, $"Validation error: {error.ToString()}");
            Assert.IsTrue(json.Display, $"Display is incorrect: {json.Display}");
            Assert.AreEqual("race", json.Name, $"Name is incorrect: {json.Name}");
            Assert.AreEqual(TemplateFieldType.RandomTable, json.TemplateObjectType, $"Type is not table");
            Assert.AreEqual("race", tbl.TableName, $"Table name is incorrect: {tbl.TableName}");
            Assert.AreEqual(0, tbl.Variables.Count, $"Table Vars != 0 : {tbl.Variables.Count}");
        }
        public void SetTemplateVarListTest()
        {
            var validator = new TemplateValidator(new MockRandomTableService(), new MockTemplateService());

            var testVal = @"[var:{""name"":""gender"",""display"":true,""value"":""lst:male, female""}]";

            var field = new TemplateField
            {
                Sort      = 1,
                Value     = testVal,
                FieldType = TemplateFieldType.Variable
            };

            var(error, result) = validator.SetVariableField(field).Result;

            var json = JsonConvert.DeserializeObject <TemplateVar>(result.TemplateJson);

            var listField = JsonConvert.DeserializeObject <TemplateField>(json.TemplateObjectJson);

            var list = JsonConvert.DeserializeObject <TemplateLst>(listField.TemplateJson);

            Assert.AreEqual(field.VariableName, "gender", $"Variable name field is incorrect: {field.VariableName}");
            Assert.AreEqual(ValidationError.None, error, $"Validation error: {error.ToString()}");
            Assert.IsTrue(json.Display, $"Display is incorrect: {json.Display}");
            Assert.AreEqual("gender", json.Name, $"Name is incorrect: {json.Name}");
            Assert.AreEqual(TemplateFieldType.List, json.TemplateObjectType, $"Type is not list");
            Assert.IsTrue(list.Values.Contains("male"), $"List does not contain male");
            Assert.IsTrue(list.Values.Contains("female"), $"List does not contain female");
        }