-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3165eaf
commit 3e09a51
Showing
25 changed files
with
216 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
using System.Net; | ||
using RestSharp.Serializers.Xml; | ||
using RestSharp.Tests.Shared.Extensions; | ||
using RestSharp.Tests.Shared.Fixtures; | ||
using RestSharp.Serializers.Xml; | ||
|
||
namespace RestSharp.Tests.Integrated; | ||
|
||
public class RootElementTests { | ||
[Fact] | ||
public async Task Copy_RootElement_From_Request_To_IWithRootElement_Deserializer() { | ||
using var server = HttpServerFixture.StartServer("success", Handle); | ||
|
||
var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseXmlSerializer()); | ||
using var server = WireMockServer.Start(); | ||
|
||
const string xmlBody = | ||
""" | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Response> | ||
<Success> | ||
<Message>Works!</Message> | ||
</Success> | ||
</Response> | ||
"""; | ||
server | ||
.Given(Request.Create().WithPath("/success")) | ||
.RespondWith(Response.Create().WithBody(xmlBody).WithHeader(KnownHeaders.ContentType, ContentType.Xml)); | ||
|
||
var client = new RestClient(server.Url!, configureSerialization: cfg => cfg.UseXmlSerializer()); | ||
|
||
var request = new RestRequest("success") { RootElement = "Success" }; | ||
|
||
var response = await client.ExecuteAsync<TestResponse>(request); | ||
|
||
response.Data.Should().NotBeNull(); | ||
response.Data!.Message.Should().Be("Works!"); | ||
|
||
static void Handle(HttpListenerRequest req, HttpListenerResponse response) { | ||
response.StatusCode = 200; | ||
response.Headers.Add(KnownHeaders.ContentType, ContentType.Xml); | ||
|
||
response.OutputStream.WriteStringUtf8( | ||
@"<?xml version=""1.0"" encoding=""utf-8"" ?> | ||
<Response> | ||
<Success> | ||
<Message>Works!</Message> | ||
</Success> | ||
</Response>" | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.