public void SutReturnsFields(DbFieldCollection sut, DbField field1, DbField field2) { sut.Add(field1); sut.Add(field2); sut.ShouldAllBeEquivalentTo(new[] { field1, field2 }); }
public void TryGetValueReturnsTrueAndValue(DbFieldCollection sut, ID fieldId, string expected) { sut.Add(fieldId, expected); string value; sut.TryGetValue(fieldId, out value).Should().BeTrue(); value.Should().Be(expected); }
public void ShouldAddDbField() { // arrange var collection = new DbFieldCollection(); // act collection.Add(new DbField("Title")); // assert collection.Count().Should().Be(1); }
public void AddFieldByNameGeneratesNewId(DbFieldCollection sut, string fieldName) { sut.Add(fieldName); sut.Single().ID.Should().NotBe(ID.Null); }
public void AddFieldByName(DbFieldCollection sut, string fieldName) { sut.Add(fieldName); sut.Single().Name.Should().Be(fieldName); }
public void AddField(DbFieldCollection sut, DbField field) { sut.Add(field); sut.Count().Should().Be(1); }
public void GetFieldById(DbFieldCollection sut, DbField field) { sut.Add(field); sut[field.ID].ShouldBeEquivalentTo(field); }
public void AddFieldByNameAndValue(DbFieldCollection sut, string fieldName, string value) { sut.Add(fieldName, value); sut.Single().Value.Should().Be(value); }
public void AddFieldByNameSetsEmptyValue(DbFieldCollection sut, string fieldName) { sut.Add(fieldName); sut.Single().Value.Should().BeEmpty(); }
public void ContainsFieldIsTrueIfExists(DbFieldCollection sut, DbField field) { sut.Add(field); sut.ContainsKey(field.ID).Should().BeTrue(); }
protected virtual void CreateTemplate(DbItem item) { var isResolved = this.ResolveTemplate(item); if (isResolved) { return; } if (!ID.IsNullOrEmpty(item.TemplateID) && this.DataStorage.GetFakeTemplate(item.TemplateID) != null) { return; } if (item.TemplateID == ID.Null) { item.TemplateID = ID.NewID; } var fields = new DbFieldCollection(); foreach (var itemField in item.Fields) { var templatefield = new DbField(itemField.Name) { ID = itemField.ID }; fields.Add(templatefield); } var template = new DbTemplate(item.Name, item.TemplateID, fields); this.Add(template); }