Skip to content

Commit f490f9a

Browse files
committed
chore: additional tests
1 parent 6b1706b commit f490f9a

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

ObjectSemantics.NET.Tests/CognitiveMapTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,33 @@ public void Should_Escape_Xml_Char_Values_If_Option_Is_Enabled(string value, str
101101
});
102102
Assert.Equal(expected, generatedTemplate);
103103
}
104+
105+
106+
[Fact]
107+
public void Additional_Headers_And_Class_Properties_Should_Also_Be_Mapped_Combined()
108+
{
109+
Payment payment = new Payment
110+
{
111+
Id = 1,
112+
Amount = 1000,
113+
PayMethod = "CHEQUE",
114+
PayMethodId = 2,
115+
ReferenceNo = "CHEQUE0001",
116+
UserId = 242
117+
};
118+
//additional params (outside the class)
119+
Dictionary<string, object> additionalParams = new Dictionary<string, object>
120+
{
121+
{ "ReceivedBy", "John Doe"},
122+
{ "NewBalance", 1050 }
123+
};
124+
125+
string generatedTemplate = payment.Map("{{Id}}-{{ ReferenceNo }} Confirmed. ${{ Amount:N2 }} received via {{ PayMethod }}({{PayMethodId}}) from user-id {{ UserId }}. New Balance: {{ NewBalance:N2 }}, Received By: {{ReceivedBy}}.", additionalParams);
126+
127+
128+
string expectedResponse = "1-CHEQUE0001 Confirmed. $1,000.00 received via CHEQUE(2) from user-id 242. New Balance: 1,050.00, Received By: John Doe.";
129+
130+
Assert.Equal(generatedTemplate, expectedResponse);
131+
}
104132
}
105133
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace ObjectSemantics.NET.Tests.MoqModels
2+
{
3+
internal class Payment
4+
{
5+
public int Id { get; set; }
6+
public int? UserId { get; set; }
7+
public double Amount { get; set; } = 0;
8+
public string PayMethod { get; set; }
9+
public int? PayMethodId { get; set; }
10+
public string ReferenceNo { get; set; }
11+
}
12+
}

0 commit comments

Comments
 (0)