示例#1
0
        public void Can_translate_generic_lists()
        {
            var values = new[] { "A", "B", "C" };
            var testA  = new TestClassA {
                FromStringList    = new ArrayOfString(values),
                ToStringList      = new List <string>(values),
                FromUserFileTypes = new List <UserFileType>
                {
                    UserFileType.DefaultProfile, UserFileType.OriginalProfile
                },
            };

            var fromTestA = testA.TranslateTo <TestClassB>();

            AssertAreEqual(testA, fromTestA);

            var userFileTypeValues = testA.FromUserFileTypes.ConvertAll(x => x.ToString());
            var testB = new TestClassB {
                FromStringList    = new List <string>(values),
                ToStringList      = new ArrayOfString(values),
                FromUserFileTypes = new ArrayOfString(userFileTypeValues),
            };

            var fromTestB = testB.TranslateTo <TestClassA>();

            AssertAreEqual(fromTestB, testB);
        }
示例#2
0
        public void Can_translate_generic_list_does_ignore_protected_setters()
        {
            var values = new[] { "A", "B", "C" };
            var testA  = new TestClassA
            {
                ToStringList = new List <string>(values),
            };

            var fromTestA = testA.TranslateTo <TestClassC>();

            Assert.NotNull(fromTestA);
            Assert.IsNull(fromTestA.FromStringList);
        }
		public void Can_translate_generic_lists()
		{
			var values = new[] { "A", "B", "C" };
			var testA = new TestClassA {
				FromStringList = new ArrayOfString(values),
				ToStringList = new List<string>(values),
				FromUserFileTypes = new List<UserFileType>
            	{
            		UserFileType.DefaultProfile, UserFileType.OriginalProfile
            	},
			};

			var fromTestA = testA.TranslateTo<TestClassB>();

			AssertAreEqual(testA, fromTestA);

			var userFileTypeValues = testA.FromUserFileTypes.ConvertAll(x => x.ToString());
			var testB = new TestClassB {
				FromStringList = new List<string>(values),
				ToStringList = new ArrayOfString(values),
				FromUserFileTypes = new ArrayOfString(userFileTypeValues),
			};

			var fromTestB = testB.TranslateTo<TestClassA>();
			AssertAreEqual(fromTestB, testB);
		}
        public void Can_translate_generic_list_does_ignore_protected_setters()
        {
            var values = new[] { "A", "B", "C" };
            var testA = new TestClassA
            {
                ToStringList = new List<string>(values),
            };

            var fromTestA = testA.TranslateTo<TestClassC>();
            Assert.NotNull(fromTestA);
            Assert.IsNull(fromTestA.FromStringList);
        }