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);
        }
		private static void AssertAreEqual(TestClassA testA, TestClassB testB)
		{
			Assert.That(testA, Is.Not.Null);
			Assert.That(testB, Is.Not.Null);

			Assert.That(testA.FromStringList, Is.Not.Null);
			Assert.That(testB.FromStringList, Is.Not.Null);
			Assert.That(testA.FromStringList,
				Is.EquivalentTo(new List<string>(testB.FromStringList)));

			Assert.That(testA.ToStringList, Is.Not.Null);
			Assert.That(testB.ToStringList, Is.Not.Null);
			Assert.That(testA.ToStringList, Is.EquivalentTo(testB.ToStringList));

			Assert.That(testA.FromUserFileTypes, Is.Not.Null);
			Assert.That(testB.FromUserFileTypes, Is.Not.Null);
			Assert.That(testA.FromUserFileTypes,
				Is.EquivalentTo(testB.FromUserFileTypes.ConvertAll(x => x.ToEnum<UserFileType>())));
		}
Beispiel #4
0
        private static void AssertAreEqual(TestClassA testA, TestClassB testB)
        {
            Assert.That(testA, Is.Not.Null);
            Assert.That(testB, Is.Not.Null);

            Assert.That(testA.FromStringList, Is.Not.Null);
            Assert.That(testB.FromStringList, Is.Not.Null);
            Assert.That(testA.FromStringList,
                        Is.EquivalentTo(new List <string>(testB.FromStringList)));

            Assert.That(testA.ToStringList, Is.Not.Null);
            Assert.That(testB.ToStringList, Is.Not.Null);
            Assert.That(testA.ToStringList, Is.EquivalentTo(testB.ToStringList));

            Assert.That(testA.FromUserFileTypes, Is.Not.Null);
            Assert.That(testB.FromUserFileTypes, Is.Not.Null);
            Assert.That(testA.FromUserFileTypes,
                        Is.EquivalentTo(testB.FromUserFileTypes.ConvertAll(x => x.ToEnum <UserFileType>())));
        }