mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 17:28:55 +02:00
58
test/WireMock.Net.XamarinUI.Tests/UIFlowTests.cs
Normal file
58
test/WireMock.Net.XamarinUI.Tests/UIFlowTests.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
using Xamarin.UITest;
|
||||
|
||||
namespace WireMock.Net.XamarinUI.Tests
|
||||
{
|
||||
[TestFixture(Platform.Android)]
|
||||
[TestFixture(Platform.iOS)]
|
||||
public class UIFlowTests
|
||||
{
|
||||
IApp app;
|
||||
Platform platform;
|
||||
|
||||
private WireMockServer _server;
|
||||
|
||||
public UIFlowTests(Platform platform)
|
||||
{
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void BeforeEachTest()
|
||||
{
|
||||
var serverSettings = new WireMockServerSettings();
|
||||
// serverSettings.Port = 5005;
|
||||
serverSettings.AllowPartialMapping = true;
|
||||
|
||||
_server = WireMockServer.Start(serverSettings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestMockServerIsWorking()
|
||||
{
|
||||
_server
|
||||
.Given(Request.Create()
|
||||
.UsingGet())
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("test"));
|
||||
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
var result = await httpClient.GetAsync(_server.Urls[0]);
|
||||
var content = await result.Content.ReadAsStringAsync();
|
||||
Assert.AreEqual("test", content);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void ShutdownServer()
|
||||
{
|
||||
_server.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user