Skip to content

Commit 4dc689f

Browse files
committed
CodeQL fixes.
1 parent 32e5486 commit 4dc689f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/CanMapIfASourceTypeTargetsMultipleDestinationTypesInTheSameExpression.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CanMapIfASourceTypeTargetsMultipleDestinationTypesInTheSameExpressi
1313
#pragma warning restore xUnit1004 // Test methods should not be skipped
1414
public void Can_map_if_source_type_targets_multiple_destination_types_in_the_same_expression()
1515
{
16+
// Arrange
1617
var mapper = ConfigurationHelper.GetMapperConfiguration(cfg =>
1718
{
1819
cfg.CreateMap<SourceType, TargetType>().ReverseMap();
@@ -23,16 +24,21 @@ public void Can_map_if_source_type_targets_multiple_destination_types_in_the_sam
2324
cfg.CreateMap<SourceListItemType, TargetChildListItemType>().ReverseMap();
2425

2526
}).CreateMapper();
26-
2727
Expression<Func<SourceType, bool>> sourcesWithListItemsExpr = src => src.Id != 0 && src.ItemList.Any() && src.Child.ItemList.Any(); // Sources with non-empty ItemList
28+
29+
// Act
2830
Expression<Func<TargetType, bool>> target1sWithListItemsExpr = mapper.MapExpression<Expression<Func<TargetType, bool>>>(sourcesWithListItemsExpr);
31+
32+
// Assert
33+
Assert.NotNull(target1sWithListItemsExpr);
2934
}
3035

3136
#pragma warning disable xUnit1004 // Test methods should not be skipped
3237
[Fact(Skip = "This test is currently skipped due to unsupported scenario.")]
3338
#pragma warning restore xUnit1004 // Test methods should not be skipped
3439
public void Can_map_if_source_type_targets_multiple_destination_types_in_the_same_expression_including_nested_parameters()
3540
{
41+
// Arrange
3642
var mapper = ConfigurationHelper.GetMapperConfiguration(cfg =>
3743
{
3844
cfg.CreateMap<SourceType, TargetType>().ReverseMap();
@@ -43,9 +49,13 @@ public void Can_map_if_source_type_targets_multiple_destination_types_in_the_sam
4349
cfg.CreateMap<SourceListItemType, TargetChildListItemType>().ReverseMap();
4450

4551
}).CreateMapper();
46-
4752
Expression<Func<SourceType, bool>> sourcesWithListItemsExpr = src => src.Id != 0 && src.ItemList.FirstOrDefault(i => i.Id == 1) == null && src.Child.ItemList.FirstOrDefault(i => i.Id == 1) == null; // Sources with non-empty ItemList
53+
54+
// Act
4855
Expression<Func<TargetType, bool>> target1sWithListItemsExpr = mapper.MapExpression<Expression<Func<TargetType, bool>>>(sourcesWithListItemsExpr);
56+
57+
//Assert
58+
Assert.NotNull(target1sWithListItemsExpr);
4959
}
5060

5161
private class SourceChildType

0 commit comments

Comments
 (0)