public void Execute_EnforeTemplateNo_NextCalled() { //Arrange var task = new EnforcedTemplateCheck(); var config = new SitecoreTypeConfiguration(); config.EnforceTemplate = SitecoreEnforceTemplate.No; bool nextCalled = false; task.SetNext(x => nextCalled = true); var args = new ObjectConstructionArgs(null, new StubAbstractTypeCreationContext(), config, null); //Act task.Execute(args); //Assert Assert.IsNull(args.Result); Assert.IsTrue(nextCalled); }
public void Execute_EnforeTemplateAndBaseDoesNotInheritTemplate_NextCalledResultNull() { //Arrange var task = new EnforcedTemplateCheck(); bool nextCalled = false; task.SetNext(x => nextCalled = true); using (Db database = new Db { new DbTemplate(new ID(TemplateInferredTypeTaskFixture.StubInferred.TemplateId)), new Sitecore.FakeDb.DbItem("Target", ID.NewID, new ID(TemplateInferredTypeTaskFixture.StubInferred.TemplateId)) }) { var path = "/sitecore/content/Target"; var item = database.GetItem(path); var config = new SitecoreTypeConfiguration(); config.EnforceTemplate = SitecoreEnforceTemplate.TemplateAndBase; config.TemplateId = new ID(Guid.NewGuid()); var typeContext = new SitecoreTypeCreationContext(); typeContext.Item = item; var args = new ObjectConstructionArgs(null, typeContext, config, null); //Act using (new SecurityDisabler()) { task.Execute(args); } //Assert Assert.IsNull(args.Result); Assert.IsTrue(nextCalled); } }