Skip to content

Commit

Permalink
Add factory service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Dec 17, 2023
1 parent 756a209 commit 66cc2c1
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ShopifySharp.Tests/Factories/OrderServiceFactoryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using FluentAssertions;
using JetBrains.Annotations;
using ShopifySharp.Credentials;
using ShopifySharp.Factories;
using Xunit;

namespace ShopifySharp.Tests.Factories;

[TestSubject(typeof(OrderServiceFactory))]
[Trait("Category", "Factories")]
public class OrderServiceFactoryTest
{
private const string ShopDomain = "some-shop-domain";
private const string AccessToken = "some-access-token";

private readonly OrderServiceFactory _factory = new();

[Fact]
public void Create_ReturnsTheService()
{
// Act
var service = _factory.Create(ShopDomain, AccessToken);

// Assert
service.Should().NotBeNull();
service.Should().BeOfType<OrderService>().And.BeAssignableTo<IOrderService>();
}

[Fact]
public void Create_WhenGivenShopifyPartnerApiCredentials_ReturnsTheService()
{
// Setup
var credentials = new ShopifyApiCredentials(ShopDomain, AccessToken);

// Act
var service = _factory.Create(credentials);

// Assert
service.Should().NotBeNull();
service.Should().BeOfType<OrderService>().And.BeAssignableTo<IOrderService>();
}
}
43 changes: 43 additions & 0 deletions ShopifySharp.Tests/Factories/PartnerServiceFactoryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#nullable enable
using FluentAssertions;
using JetBrains.Annotations;
using ShopifySharp.Credentials;
using ShopifySharp.Factories;
using Xunit;

namespace ShopifySharp.Tests.Factories;

[TestSubject(typeof(PartnerServiceFactory))]
[Trait("Category", "Factories")]
public class PartnerServiceFactoryTest
{
private const long OrganizationId = 123L;
private const string AccessToken = "some-access-token";

private readonly PartnerServiceFactory _factory = new();

[Fact]
public void Create_ReturnsTheService()
{
// Act
var service = _factory.Create(OrganizationId, AccessToken);

// Assert
service.Should().NotBeNull();
service.Should().BeOfType<PartnerService>().And.BeAssignableTo<IPartnerService>();
}

[Fact]
public void Create_WhenGivenShopifyPartnerApiCredentials_ReturnsTheService()
{
// Setup
var credentials = new ShopifyPartnerApiCredentials(OrganizationId, AccessToken);

// Act
var service = _factory.Create(credentials);

// Assert
service.Should().NotBeNull();
service.Should().BeOfType<PartnerService>().And.BeAssignableTo<IPartnerService>();
}
}

0 comments on commit 66cc2c1

Please sign in to comment.