Skip to content

Commit

Permalink
add unit tests for the new trim extension
Browse files Browse the repository at this point in the history
  • Loading branch information
corranrogue9 committed Aug 29, 2023
1 parent f2f3653 commit 0e1f2e6
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,50 @@ public void TestTrimEndingTypeCast()
}
}

[Fact]
public void TrimEndingTypeAndKeySegments()
{
var testCases = new[]
{
new {
Url = "People",
Trimmed = "People"
},
new {
Url = "People(1)",
Trimmed = "People"
},
new {
Url = "People/Fully.Qualified.Namespace.Employee",
Trimmed = "People"
},
new {
Url = "People(1)/Fully.Qualified.Namespace.Employee",
Trimmed = "People"
},
new {
Url = "People/Fully.Qualified.Namespace.Employee/1",
Trimmed = "People"
},
new {
Url = "People/Fully.Qualified.Namespace.Employee/1/MyAddress",
Trimmed = "People/Fully.Qualified.Namespace.Employee/1/MyAddress"
},
new {
Url = "People(1)/Fully.Qualified.Namespace.Employee/MyAddress",
Trimmed = "People/1/Fully.Qualified.Namespace.Employee/MyAddress"
},
};

foreach (var testCase in testCases)
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, this.testBaseUri, new Uri(this.testBaseUri, testCase.Url));
ODataPath path = parser.ParsePath();
var result = path.TrimEndingTypeAndKeySegments();
Assert.Equal(testCase.Trimmed, result.ToResourcePathString(ODataUrlKeyDelimiter.Slash));
}
}

[Fact]
public void TestIsIndividualProperty()
{
Expand Down

0 comments on commit 0e1f2e6

Please sign in to comment.