public void FromObject_NullTarget_ThrowException() { var exception = Assert.Throws <ArgumentNullException>(() => SetFields.FromObject(null, null)); exception.ShouldBeOfType <ArgumentNullException>(); exception.ShouldNotBeNull(); exception.ParamName.ShouldBe("target"); }
/// <summary> /// 使用字段名指定需要更新的字段,性能稍微好些,如 “ID” /// </summary> /// <param name="fieldName"></param> /// <returns></returns> public IUpdatePartial <TTable> Set(String fieldName) { if (!String.IsNullOrEmpty(fieldName)) { SetFields.Enqueue(fieldName.ToLower()); } return(this); }
public void FromObject_NotNullSourceAndTargetWithExtraProperty_Success() { var target = new Demo(); var id = Guid.Parse("{6E25FEB7-771E-4194-BAA2-4184F54C4953}"); var source = new { Id = id, Name = "Alper", Code = 1 }; SetFields.FromObject(target, source); target.Id.ShouldBe(id); target.Name.ShouldBe("Alper"); }
public override bool ValidateSelectors() => ( !string.IsNullOrEmpty(PageReference) && !string.IsNullOrEmpty(Table) && !string.IsNullOrEmpty(LoadElement) && SetFields.Any() && GetFields.Any() && PageButtons.Any() && TableFields.Any() && ErrorElements.Any() );
public void FromObject_NotNullSourceAndTargetAndMapping_Success() { var target = new Demo(); var id = Guid.Parse("{6E25FEB7-771E-4194-BAA2-4184F54C4953}"); var source = new { id = id, name = "Alper" }; var mapping = new List <MapperItem>() { new MapperItem { ColumnName = "id", PropertyName = "Id" }, new MapperItem { ColumnName = "name", PropertyName = "Name" } }; SetFields.FromObjectWithMapping(target, source, mapping); target.Id.ShouldBe(id); target.Name.ShouldBe("Alper"); }
public void FromObject_NullSource_DoNothing() { SetFields.FromObject(GetType(), null); }