Esempio n. 1
0
        public void TmplCopy_With_CustomTypeCast_ForOtherTmpl_Test()
        {
            var src = new TmplCopy <MyItem_WithoutCast>()
            {
                A = new MyItem_WithoutCast()
                {
                    A = 1
                }
            };
            var dst = new TmplCopy <int>();

            var casts = new DtoCopierCastStorage();

            casts.Append(typeof(MyItem_WithoutCast).GetMethod(nameof(MyItem_WithoutCast.ToInt)), typeof(OtherTmplCopy <>));

            AssertionExtensions.Should(() => new DtoCopier(casts).Copy(dst, typeof(TmplCopy <int>), src, typeof(TmplCopy <MyItem_WithoutCast>), false, null))
            .Throw <InvalidOperationException>();
        }
Esempio n. 2
0
        public void TmplCopy_With_CustomTypeCast_Test()
        {
            var src = new TmplCopy <MyItem_WithoutCast>()
            {
                A = new MyItem_WithoutCast()
                {
                    A = 1
                }
            };
            var dst = new TmplCopy <int>();

            var casts = new DtoCopierCastStorage();

            casts.Append(typeof(MyItem_WithoutCast).GetMethod(nameof(MyItem_WithoutCast.ToInt)), typeof(TmplCopy <>));

            new DtoCopier(casts).Copy(dst, typeof(TmplCopy <int>), src, typeof(TmplCopy <MyItem_WithoutCast>), false, null);

            dst.A.Should().Be(1);
        }