public void WrongTypeShouldReturnNull(string fieldType) { //Arrange using (var db = new Db { new ItemBuilder().WithReference(fieldType).AddSubItem().Build() }) { var item = db.GetItem("/sitecore/content/source"); var field = item.Fields[ItemBuilder.ReferenceFieldName]; var args = new SitecoreItemDataField(field); var sut = new ReferenceFieldReader(); //Act var actual = sut.GetFieldValue(args); //Assert actual.Should().BeNull(); } }
public void NoReferenceShouldNotFail() { //Arrange using (var db = new Db { new ItemBuilder().WithReference("droplink").Build() }) { var item = db.GetItem("/sitecore/content/source"); var field = item.Fields[ItemBuilder.ReferenceFieldName]; var args = new SitecoreItemDataField(field); var sut = new ReferenceFieldReader(); //Act var actual = sut.GetFieldValue(args); //Assert actual.Should().BeNull(); } }
public void ShouldReturnReferenceName(string fieldType) { //Arrange using (var db = new Db { new ItemBuilder().WithReference(fieldType).AddSubItem().Build() }) { var item = db.GetItem("/sitecore/content/source"); var field = item.Fields[ItemBuilder.ReferenceFieldName]; var args = new SitecoreItemDataField(field); var sut = new ReferenceFieldReader(); //Act var actual = sut.GetFieldValue(args); //Assert actual.Should().BeOfType <string>(); var result = actual as string; result.Should().Be("subitem"); } }