-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for overriding BuildRequestUri
- Loading branch information
1 parent
488f80b
commit f854fd0
Showing
3 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using FluentAssertions; | ||
using JetBrains.Annotations; | ||
using ShopifySharp.Tests.TestClasses; | ||
using Xunit; | ||
|
||
namespace ShopifySharp.Tests.Services; | ||
|
||
[Trait("Category", "ShopifyService")] | ||
[TestSubject(typeof(ShopifyService))] | ||
public class ShopifyServiceTests | ||
{ | ||
#region PrepareRequest(string path) and BuildRequestUri | ||
|
||
[Fact] | ||
public void BuildRequestUri_ShouldReturnOverridenUri() | ||
{ | ||
// Setup | ||
var expectedUri = new Uri("https://some-expected-uri.com", UriKind.Absolute); | ||
var service = new TestBuildRequestUriShopifyService(expectedUri); | ||
|
||
// Act | ||
var result = service.BuildRequestUriProxy(); | ||
|
||
// Assert | ||
result.ToUri().Should().Be(expectedUri); | ||
} | ||
|
||
#endregion | ||
} |
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
21 changes: 21 additions & 0 deletions
21
ShopifySharp.Tests/TestClasses/TestBuildRequestUriShopifyService.cs
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#nullable enable | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ShopifySharp.Infrastructure; | ||
|
||
namespace ShopifySharp.Tests.TestClasses; | ||
|
||
/// <summary> | ||
/// A test ShopifyService that overrides the <see cref="ShopifyService.BuildRequestUri(string)"/> method for testing. | ||
/// </summary> | ||
/// <param name="requestUri">The uri you want the overriden <see cref="ShopifyService.BuildRequestUri(string)"/> to return for testing.</param> | ||
public class TestBuildRequestUriShopifyService(Uri requestUri) : ShopifyService("some-shop-domain", "some-access-token") | ||
{ | ||
protected override RequestUri BuildRequestUri(string _) | ||
{ | ||
return new RequestUri(requestUri); | ||
} | ||
|
||
public RequestUri BuildRequestUriProxy() => BuildRequestUri("some-path"); | ||
} |