Files
WireMock.Net/test/WireMock.Net.Tests/Util/UrlUtilsTests.cs
Stef Heyenrath 54edf0bebc Add link to TIOBE Index on main page + fix issues (#1137)
* Add TIOBE + include SonarAnalyzer.CSharp

* .

* cp

* Copyright © WireMock.Net

* more fixes

* fix

* xpath

* if (Matchers == null || !Matchers.Any())

* if (Matchers != null)

* ?

* .

* .
2024-07-18 18:06:04 +02:00

58 lines
1.5 KiB
C#

// Copyright © WireMock.Net
using System;
#if NET452
using Microsoft.Owin;
#else
using Microsoft.AspNetCore.Http;
#endif
using NFluent;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
public class UrlUtilsTests
{
[Fact]
public void UriUtils_CreateUri_WithValidPathString()
{
// Assign
Uri uri = new Uri("https://localhost:1234/a/b?x=0");
// Act
var result = UrlUtils.Parse(uri, new PathString("/a"));
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
}
[Fact]
public void UriUtils_CreateUri_WithEmptyPathString()
{
// Assign
Uri uri = new Uri("https://localhost:1234/a/b?x=0");
// Act
var result = UrlUtils.Parse(uri, new PathString());
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/a/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
}
[Fact]
public void UriUtils_CreateUri_WithDifferentPathString()
{
// Assign
Uri uri = new Uri("https://localhost:1234/a/b?x=0");
// Act
var result = UrlUtils.Parse(uri, new PathString("/test"));
// Assert
Check.That(result.Url.ToString()).Equals("https://localhost:1234/a/b?x=0");
Check.That(result.AbsoluteUrl.ToString()).Equals("https://localhost:1234/a/b?x=0");
}
}