public void DestinationCollectionHasSameNumberOfItemsAsSource() { TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>(); CollectionMapper<T1, int, T2, int> collectionMapper = new CollectionMapper<T1, int, T2, int>( mapper, t => t.IntCollection, () => new List<int>(), null, t => t.IntCollection, () => new List<int>(), null); T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } }; T2 t2 = mapper.Forward().Map(t1); T1 t3 = mapper.Reverse().Map(t2); Assert.AreEqual(t1.IntCollection.Count, t2.IntCollection.Count); Assert.AreEqual(t1.IntCollection.Count, t1.IntCollection.Count); }
public void ConvertedPrimitiveDestinationCollectionHasEquivalentItemsAsSource() { TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>(); CollectionMapper<T1, int, T2, long> collectionMapper = new CollectionMapper<T1, int, T2, long>( mapper, t => t.IntCollection, () => new List<int>(), null, t => t.LongCollection, () => new List<long>(), null); T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } }; T2 t2 = mapper.Forward().Map(t1); T1 t3 = mapper.Reverse().Map(t2); Assert.IsTrue(t1.IntCollection.All(i => t2.LongCollection.Any(l => i == l))); Assert.IsTrue(t2.LongCollection.All(i => t3.IntCollection.Any(l => i == l))); }
public void PrimitiveDestinationCollectionHasSameItemsAsSource() { TypeMapper<T1, T2> mapper = new TypeMapper<T1, T2>(); CollectionMapper<T1, int, T2, int> collectionMapper = new CollectionMapper<T1, int, T2, int>( mapper, t => t.IntCollection, () => new List<int>(), null, t => t.IntCollection, () => new List<int>(), null); T1 t1 = new T1() { IntCollection = new[] { 1, 2, 3 } }; T2 t2 = mapper.Forward().Map(t1); T1 t3 = mapper.Reverse().Map(t2); Assert.IsFalse(t1.IntCollection.Except(t2.IntCollection).Any()); Assert.IsFalse(t2.IntCollection.Except(t3.IntCollection).Any()); }