forked from MapsterMapper/Mapster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhenAddCtorNullablePropagation.cs
More file actions
51 lines (38 loc) · 1.35 KB
/
WhenAddCtorNullablePropagation.cs
File metadata and controls
51 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Mapster.Tests.Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
namespace Mapster.Tests
{
[TestClass]
public class WhenAddCtorNullablePropagation
{
/// <summary>
/// https://github.com/MapsterMapper/Mapster/issues/898
/// </summary>
[TestMethod]
public void NullablePropagationFromCtorWorking()
{
var source = new List<OrderEntity898>();
source.Add(new OrderEntity898() { Id = 1, Cod = new OrderCodEntity898 { Value = 42L } });
source.Add(new OrderEntity898() { Id = 2, Cod = null });
var str = new OrderEntity898() { Id = 1, Cod = new OrderCodEntity898 { Value = 42L } }.BuildAdapter().CreateProjectionExpression<OrderDto898>();
var result = source.AsQueryable().ProjectToType<OrderDto898>().ToList();
}
}
#region TestClasses
public record OrderDto898(int Id, OrderCodDto898? Cod);
public record OrderCodDto898(long Value);
public class OrderEntity898
{
public int Id { get; set; }
public int? CodId { get; set; }
public OrderCodEntity898? Cod { get; set; }
}
public class OrderCodEntity898
{
public int Id { get; set; }
public long Value { get; set; }
}
#endregion TestClasses
}