public void ParseFields_ReturnsExpectedValues(string fieldValue, string standardValue, string expected) { using (var db = new Db()) { var testFieldId = ID.NewID; var template = new DbTemplate("Test Template") { { testFieldId, standardValue } }; db.Add(template); var testItem = ItemManager.CreateItem("Test", db.GetItem(ItemIDs.ContentRoot), template.ID); if (expected != null) { using (new EditContext(testItem)) { testItem[testFieldId] = expected; } } var sut = new FieldReader(); testItem.Fields.ReadAll(); var result = sut.ParseFields(testItem, FieldReader.FieldReadType.Versioned).FirstOrDefault(f => f.FieldId == testFieldId.Guid); if (expected == null) result.Should().BeNull(); else result.Value.Should().Be(expected); } }
public void ParseFields_ReturnsExpectedValues(string fieldValue, string standardValue, string expected) { using (var db = new Db()) { var testFieldId = ID.NewID; var template = new DbTemplate("Test Template") { { testFieldId, standardValue } }; db.Add(template); var testItem = ItemManager.CreateItem("Test", db.GetItem(ItemIDs.ContentRoot), template.ID); if (expected != null) { using (new EditContext(testItem)) { testItem[testFieldId] = expected; } } var sut = new FieldReader(); testItem.Fields.ReadAll(); var result = sut.ParseFields(testItem, FieldReader.FieldReadType.Versioned).FirstOrDefault(f => f.FieldId == testFieldId.Guid); if (expected == null) { result.Should().BeNull(); } else { result.Value.Should().Be(expected); } } }