public void Validate_WithStrongType_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedCopier_StrongValidatorType)); var obj = new CopyClass0(); var issues = dto.Validate(obj, x => x.RuleFor(t => t).ValidateDto()).Issues; issues.Should().HaveCount(1); }
public void Validate_WithBaseClass_Test1() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedCopierContainer0), typeof(NestedCopierContainer1)); var obj = new CopyClass0() { A = -1 }; dto.Validate(obj, x => x.RuleFor(t => t).ValidateDto()).Issues.Should().HaveCount(1); }
public void As_WithUnknown_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedForAs)); var obj = new CopyClass0() { A = 1 }; var t0 = dto.As <ICopyClass0>(obj); t0.Should().BeNull(); }
public void Validate_NotPublicDescription_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedCopierContainer0), typeof(NestedCopierContainer1)); var obj = new CopyClass0() { A = -1 }; var issues = dto.Validate(obj, x => x.RuleFor(t => t).ValidateDto()).Issues; issues.Should().HaveCount(1); }
public void Copy_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedCopierContainer0)); var it = new CopyClass0(); var res = dto.Copy(it, new CopyClass0() { A = 2 }); res.Should().BeSameAs(it); res.A.Should().Be(2); }
public void Copy_FromAbstractObject_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedWithAbstractConverter)); var obj = new CopyClass0() { A = 1 }; var res = dto.Copy(new CopyClass1(), new[] { obj }); res.B.Should().Be("1"); }
public void Copy_NestedWithGenerics_WithIgnore_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedWithGenerics_WithIgnore)); var src = new CopyClass0() { A = 1 }; var dst = new CopyClass_MyTemplateItem(); var res = dto.Copy(dst, src); res.A.Should().BeNull(); }
public void Update_NestedWithGenerics_Test1() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedWithGenerics)); var src = new CopyClass0() { A = 1 }; var dst = new CopyClass_MyTemplateItem(); var res = dto.Update(dst, src); res.A.Should().BeNull(); }
public void Copy_ToAbstractObject_Test() { var dto = new DtoComplex().ByNestedClasses(typeof(NestedWithAbstractConverter)); var obj = new CopyClass0() { A = 1 }; var res = dto.Copy(new List <string>(), new CopyClass1() { B = "1" }); res.Single().Should().Be("1"); }
static void Convert(ICopyClass1 dst, CopyClass0 src) { dst.B = src.A.ToString(); }