Example #1
0
        public void InsertTemplateWithUrlAttribute()
        {
            var tag = new InsertTemplate()
            {
                Template = new MockAttribute(new Constant("insertDMaster.htm"))
            };

            tag.Factory = _factory;
            var moduleAttribute = new PutAttribute()
            {
                Name  = new MockAttribute(new Constant("modules")),
                Value = new MockAttribute(new Constant("insertDAdditional.htm"))
            };

            tag.AddNestedTag(moduleAttribute);
            var bodyAttribute = new PutAttribute()
            {
                Name  = new MockAttribute(new Constant("body")),
                Value = new MockAttribute(new Constant("Dit is de Test Body"))
            };

            tag.AddNestedTag(bodyAttribute);
            string expected = (new StreamReader("insertDExpected.htm")).ReadToEnd();
            string value    = tag.Evaluate(_model);

            Assert.That(value, Is.EqualTo(expected));
        }
Example #2
0
        public void InsertTemplateWithIllegalAttribute()
        {
            var tag = new InsertTemplate()
            {
                Template = new MockAttribute(new Constant("insertEMaster.htm"))
            };

            tag.Factory = _factory;
            var setAttribute = new Set
            {
                Var  = new MockAttribute(new Constant("body")),
                Body = new MockAttribute(new Constant("Dit is de Test Body"))
            };

            try
            {
                tag.AddNestedTag(setAttribute);
                string expected = (new StreamReader("insertEExpected.htm")).ReadToEnd();
                tag.Evaluate(_model);
                Assert.Fail("Expect exception");
            }
            catch (TagException Te)
            {
                Assert.That(Te.Message,
                            Is.EqualTo(
                                TagException.OnlyNestedTagsOfTypeAllowed(setAttribute.GetType(), typeof(PutAttribute)).
                                Message));
            }
        }
Example #3
0
        public void InsertTemplate()
        {
            var tag = new InsertTemplate()
            {
                Template = new MockAttribute(new Constant("insertAMaster.htm"))
            };

            tag.Factory = _factory;
            string expected = (new StreamReader("insertAExpected.htm")).ReadToEnd();
            string value    = tag.Evaluate(_model);

            Assert.That(value, Is.EqualTo(expected));
        }
Example #4
0
        public override void StaticSqlStringCache(SqlModel model, Type type)
        {
            GsOperator gs = new GsOperator(typeof(SqlEntity <>), type);

            gs["SetPrimary"] = MebOperator.Setter(type, model.PrimaryKey);
            gs["Table"]      = model.TableName;
            gs["Primary"]    = model.PrimaryKey;

            CountTemplate count = new CountTemplate();

            gs["SelectCount"]      = count.SelectCount(model);
            gs["SelectCountWhere"] = count.SelectCountWhere(model);


            SelectTemplate select = new SelectTemplate();

            gs["SelectAll"]          = select.SelectAll(model);
            gs["SelectAllWhere"]     = select.SelectAllWhere(model);
            gs["SelectAllByPrimary"] = select.SelectAllByPrimary(model);
            gs["SelectAllIn"]        = select.SelectAllIn(model);


            UpdateTemplate update = new UpdateTemplate();

            gs["UpdateAllWhere"]     = update.UpdateWhere(model);
            gs["UpdateAllByPrimary"] = update.UpdateByPrimary(model);


            InsertTemplate insert = new InsertTemplate();

            gs["InsertAll"] = insert.Insert(model);


            DeleteTemplate delete = new DeleteTemplate();

            gs["DeleteWhere"]     = delete.DeleteWhere(model);
            gs["DeleteByPrimary"] = delete.DeleteByPrimary(model);

            RepeateTemplate repeate      = new RepeateTemplate();
            var             repeateModel = model.ModelWithAttr <NoRepeateAttribute>();

            gs["RepeateCount"]    = repeate.RepeateCount(repeateModel);
            gs["RepeateId"]       = repeate.RepeateId(repeateModel);
            gs["RepeateEntities"] = repeate.RepeateEntities(repeateModel);
        }
Example #5
0
        public void CheckWhenRequired()
        {
            var tag = new InsertTemplate();

            try
            {
                RequiredAttribute.Check(tag);
                Assert.Fail("Expected exception");
            }
            catch (TagException Te)
            {
                Assert.That(Te.Message,
                            Is.EqualTo(
                                TagException.MissingRequiredAttribute(typeof(InsertTemplate), "Template").Message));
            }
            tag.Factory  = new FileLocatorFactory().CloneForTagLib(new TagLib().Register(new Tags.Tiles()));
            tag.Template = new MockAttribute(new Property("tiles"));
            RequiredAttribute.Check(tag);
        }
Example #6
0
        public void InsertTemplateWithOneSimpleAttribute()
        {
            var tag = new InsertTemplate()
            {
                Template = new MockAttribute(new Constant("insertBMaster.htm"))
            };

            tag.Factory = _factory;
            var titleAttribute = new PutAttribute()
            {
                Name  = new MockAttribute(new Constant("title")),
                Value = new MockAttribute(new Constant("Dit is de Test Title"))
            };

            tag.AddNestedTag(titleAttribute);
            string expected = (new StreamReader("insertBExpected.htm")).ReadToEnd();
            string value    = tag.Evaluate(_model);

            Assert.That(value, Is.EqualTo(expected));
        }
Example #7
0
        public void InsertTemplateCachesTile()
        {
            var tag = new InsertTemplate()
            {
                Template = new MockAttribute(new Constant("insertEMaster.htm"))
            };

            tag.Factory = _factory;
            var bodyAttribute = new PutAttribute()
            {
                Name = new MockAttribute(new Constant("body")),
                Body = new MockAttribute(new Constant("Dit is de Test Body"))
            };

            tag.AddNestedTag(bodyAttribute);
            tag.Evaluate(_model);
            var tile = tag.Tile;

            tag.Evaluate(_model);
            Assert.That(tag.Tile, Is.SameAs(tile));
        }