コード例 #1
0
        public void SetRandomTableExistsWithBadVariablesNestedTest()
        {
            var validator = new TemplateValidator(new MockRandomTableService(), new MockTemplateService());

            var testVal = "[tbl:{Var 1 Test {Var 2}} Table]";

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

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

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

            Assert.AreEqual(ValidationError.InvalidTag, error, $"Validation error: {error.ToString()}");
            Assert.AreEqual("{Var 1 Test {Var 2}} Table", json.TableName, $"Table value was incorrect: {json}");
        }
コード例 #2
0
        public void SetRandomTableExistsTrailingWhiteSpaceTest()
        {
            var validator = new TemplateValidator(new MockRandomTableService(), new MockTemplateService());

            var testVal = "[tbl: Test Table ]";

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

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

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

            Assert.AreEqual(ValidationError.None, error, $"Validation error: {error.ToString()}");
            Assert.AreEqual("Test Table", json.TableName, $"Table value was incorrect: {json}");
            Assert.AreEqual(0, json.Variables.Count, $"There should be no variables set");
        }