-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLegacyMappingClassesTests.cs
More file actions
130 lines (109 loc) · 4.12 KB
/
LegacyMappingClassesTests.cs
File metadata and controls
130 lines (109 loc) · 4.12 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using FluentAssertions;
using Microsoft.CodeAnalysis;
using Moq;
using Xunit;
namespace ProjectR.Tests.Mapping;
public class LegacyMappingClassesTests
{
[Fact]
public void MappingInstruction_IsAbstractBaseClass()
{
// Assert
typeof(MappingInstruction).Should().BeAbstract();
}
[Fact]
public void NestedObjectMapperMapping_InheritsFromMappingInstruction()
{
// Assert
typeof(NestedObjectMapperMapping).Should().BeDerivedFrom<MappingInstruction>();
}
[Fact]
public void NestedObjectMapperMapping_Properties_CanBeSetAndRetrieved()
{
// Arrange
var mockSourceProperty = new Mock<IPropertySymbol>();
var mockDestinationProperty = new Mock<IPropertySymbol>();
var mockMapperType = new Mock<INamedTypeSymbol>();
var mapping = new NestedObjectMapperMapping();
// Act
mapping.SourceProperty = mockSourceProperty.Object;
mapping.DestinationProperty = mockDestinationProperty.Object;
mapping.MapperType = mockMapperType.Object;
// Assert
mapping.SourceProperty.Should().Be(mockSourceProperty.Object);
mapping.DestinationProperty.Should().Be(mockDestinationProperty.Object);
mapping.MapperType.Should().Be(mockMapperType.Object);
}
[Fact]
public void ParameterMapping_Properties_CanBeSetAndRetrieved()
{
// Arrange
var mapping = new ParameterMapping();
var sourcePropertyName = "SourceProperty";
var destinationParameterName = "destinationParam";
// Act
mapping.SourcePropertyName = sourcePropertyName;
mapping.DestinationParameterName = destinationParameterName;
// Assert
mapping.SourcePropertyName.Should().Be(sourcePropertyName);
mapping.DestinationParameterName.Should().Be(destinationParameterName);
}
[Fact]
public void PropertyMapping_InheritsFromMappingInstruction()
{
// Assert
typeof(PropertyMapping).Should().BeDerivedFrom<MappingInstruction>();
}
[Fact]
public void PropertyMapping_Properties_CanBeSetAndRetrieved()
{
// Arrange
var mapping = new PropertyMapping();
var sourcePropertyName = "SourceProperty";
var destinationPropertyName = "DestinationProperty";
// Act
mapping.SourcePropertyName = sourcePropertyName;
mapping.DestinationPropertyName = destinationPropertyName;
// Assert
mapping.SourcePropertyName.Should().Be(sourcePropertyName);
mapping.DestinationPropertyName.Should().Be(destinationPropertyName);
}
[Fact]
public void PropertyMappingInstruction_IsAbstractBaseClass()
{
// Assert
typeof(PropertyMappingInstruction).Should().BeAbstract();
}
[Fact]
public void PropertyMappingInstruction_InheritsFromMappingInstruction()
{
// Assert
typeof(PropertyMappingInstruction).Should().BeDerivedFrom<MappingInstruction>();
}
[Fact]
public void PropertyMappingInstruction_Constructor_SetsDestinationProperty()
{
// Arrange
var mockDestinationProperty = new Mock<IPropertySymbol>();
// Act
var instruction = new TestPropertyMappingInstruction(mockDestinationProperty.Object);
// Assert
instruction.DestinationProperty.Should().Be(mockDestinationProperty.Object);
}
[Fact]
public void PropertyMappingInstruction_DestinationProperty_IsReadOnly()
{
// Arrange
var mockDestinationProperty = new Mock<IPropertySymbol>();
var instruction = new TestPropertyMappingInstruction(mockDestinationProperty.Object);
// Assert
var property = typeof(PropertyMappingInstruction).GetProperty(nameof(PropertyMappingInstruction.DestinationProperty));
property!.CanWrite.Should().BeFalse();
property.CanRead.Should().BeTrue();
}
// Test implementation of abstract PropertyMappingInstruction
private class TestPropertyMappingInstruction : PropertyMappingInstruction
{
public TestPropertyMappingInstruction(IPropertySymbol destinationProperty) : base(destinationProperty) { }
}
}