예제 #1
0
        public void DelegateMapper_Works()
        {
            var foo = new Foo()
            {
                A = 5,
                B = 10
            };

            var mapper = new DelegateMapper <Foo, Bar>((source, destination) =>
            {
                destination.A = source.A;
                destination.B = source.B;
                destination.C = 15;
            });

            var @new = mapper.Map(foo);

            Assert.AreEqual(@new.A, 5);
            Assert.AreEqual(@new.B, 10);
            Assert.AreEqual(@new.C, 15);
            Assert.AreEqual(@new.E, null);

            var existing = new Bar();

            mapper.Map(foo, existing);
            Assert.AreEqual(existing.A, 5);
            Assert.AreEqual(existing.B, 10);
            Assert.AreEqual(existing.C, 15);
            Assert.AreEqual(existing.E, null);
        }
예제 #2
0
        public void Converts()
        {
            var mapper = new DelegateMapper <User>(ConvertRecord);

            var record = Substitute.For <IDataRecord>();
            var actual = mapper.Map(record);

            Assert.NotNull(actual);
        }
예제 #3
0
        public void Converts()
        {
            var mapper = new DelegateMapper<User>(ConvertRecord);

            var record = Substitute.For<IDataRecord>();
            var actual = mapper.Map(record);

            Assert.NotNull(actual);
        }
        public void MapValueCallsDelegateWithArg()
        {
            var options = new MyOptions();
            var value   = string.Empty;
            var mapper  = new DelegateMapper <MyOptions, string>((opt, val) =>
            {
                value = val;
                opt.ShouldBeSameAs(options);
            }, false);

            mapper.MapValue(options, "test");
            value.ShouldBe("test");
        }