-
Notifications
You must be signed in to change notification settings - Fork 394
Closed
Labels
Description
Hi! Am I right that failing assert in this test means bug?
In version 6.5.1 it works fine.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
namespace Mapster.Tests
{
[TestClass]
public class WhenMappingStructInObject
{
class Destination
{
public TestStruct TestStruct { get; set; }
}
class SourceWithClass
{
public SourceWithStruct SourceWithStruct { get; set; }
}
class SourceWithStruct
{
public TestStruct TestStruct { get; set; }
}
struct TestStruct
{
public string Property { get; }
public TestStruct(string property) : this()
{
Property = property;
}
}
[TestMethod]
public void TestMapping()
{
TypeAdapterConfig<SourceWithClass, Destination>
.ForType()
.Map(x => x.TestStruct, x => x.SourceWithStruct.TestStruct);
var source = new SourceWithClass
{
SourceWithStruct = new SourceWithStruct
{
TestStruct = new TestStruct("A")
}
};
var destination = source.Adapt<Destination>();
destination.TestStruct.Property.ShouldBe("A");
}
}
}
Reactions are currently unavailable