diff --git a/src/Mapster.Tests/WhenMappingMapToTargetMixedReadOnlyBaseRegression.cs b/src/Mapster.Tests/WhenMappingMapToTargetMixedReadOnlyBaseRegression.cs new file mode 100644 index 00000000..d83f7f06 --- /dev/null +++ b/src/Mapster.Tests/WhenMappingMapToTargetMixedReadOnlyBaseRegression.cs @@ -0,0 +1,38 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Shouldly; + +namespace Mapster.Tests +{ + /// + /// https://github.com/MapsterMapper/Mapster/issues/918 + /// + [TestClass] + public class WhenMappingMapToTargetMixedReadOnlyBaseRegression + { + [TestMethod] + public void MapToTarget_SameType_WithMixedReadOnlyBaseProperties_UpdatesDestination() + { + var source = new Station918 { RowNo = 100, Location = "Source" }; + var destination = new Station918 { RowNo = 0, Location = "Destination" }; + + source.Adapt(destination); + + destination.RowNo.ShouldBe(100); + destination.Location.ShouldBe("Source"); + } + + public abstract class ValidationBase918 + { + public bool HasErrors { get; } + + public string? ErrorMessage { get; } + } + + public class Station918 : ValidationBase918 + { + public int RowNo { get; set; } + + public string Location { get; set; } = string.Empty; + } + } +}