Skip to content

Commit

Permalink
Added tests for mappint list to array and array to list.
Browse files Browse the repository at this point in the history
  • Loading branch information
satano committed Jun 10, 2017
1 parent 468832a commit c1641ee
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/Mapster.Tests/WhenMappingArrays.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using System;
using System.Collections.Generic;

namespace Mapster.Tests
{
Expand Down Expand Up @@ -81,6 +81,28 @@ public void Jagged_Array_Is_Mapped()
target.IntsRank3.ShouldBe(source.IntsRank3);
}

[TestMethod]
public void List_To_Array_Is_Mapped()
{
var source = new FooList { Ints = new List<int>(new int[] { 1, 2, 3, 4, 5 }) };
var target = new BarArray();

TypeAdapter.Adapt(source, target);
target.Ints.Length.ShouldBe(source.Ints.Count);
target.Ints.ShouldBe(source.Ints);
}

[TestMethod]
public void Array_To_List_Is_Mapped()
{
var source = new FooArray { Ints = new int[] { 1, 2, 3, 4, 5 } };
var target = new BarList();

TypeAdapter.Adapt(source, target);
target.Ints.Count.ShouldBe(source.Ints.Length);
target.Ints.ShouldBe(source.Ints);
}

#endregion

#region TestClasses
Expand All @@ -95,6 +117,16 @@ private class BarArray
public int[] Ints { get; set; }
}

private class FooList
{
public List<int> Ints { get; set; }
}

private class BarList
{
public List<int> Ints { get; set; }
}

private class FooArrayMultiDimensional
{
public int[,] IntsRank2 { get; set; }
Expand Down

0 comments on commit c1641ee

Please sign in to comment.