Skip to content

Instantly share code, notes, and snippets.

@rog1039
Last active November 27, 2018 20:07
Show Gist options
  • Save rog1039/9f6f6d99f2ec97d48a2691c4b9b13656 to your computer and use it in GitHub Desktop.
Save rog1039/9f6f6d99f2ec97d48a2691c4b9b13656 to your computer and use it in GitHub Desktop.
Simpler Automapper Test Case
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Shouldly;
using Xunit;
namespace AutoMapper.UnitTests2
{
public class HolderTests
{
private IMapper _mapper;
[Fact()]
[Trait("Category", "Instant")]
public void MethodName()
{
//Create Mapper.
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<ObjectOne, ObjectTwo>();
cfg.CreateMap<ObjectTwo, ObjectOne>();
});
//Fails in the line above so the code below doesn't even run.
config.AssertConfigurationIsValid();
_mapper = config.CreateMapper();
}
}
public class ObjectOne
{
public byte[] Image { get; set; }
}
public class ObjectTwo
{
public Holder<byte[]> Image { get; private set; } = new Holder<byte[]>();
}
public class Holder<T>
{
public T Value { get; set; }
public void SetValue(object o) => Value = (T) o;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment