Skip to content

Commit

Permalink
Rename Customer_Tests to CustomerServiceTests
Browse files Browse the repository at this point in the history
Move CustomerServiceTests to Services folder
  • Loading branch information
nozzlegear committed Jul 18, 2024
1 parent 742366a commit f540daa
Showing 1 changed file with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
using ShopifySharp.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using FluentAssertions;
using ShopifySharp.Filters;
using Xunit;
using Xunit.Abstractions;
using EmptyAssert = ShopifySharp.Tests.Extensions.EmptyExtensions;
// ReSharper disable PossibleInvalidOperationException

namespace ShopifySharp.Tests;
namespace ShopifySharp.Tests.Services;

[Trait("Category", "Customer")]
public class Customer_Tests : IClassFixture<Customer_Tests_Fixture>
public class CustomerServiceTests(
CustomerServiceTestsFixture fixture,
ITestOutputHelper testOutputHelper)
: IClassFixture<CustomerServiceTestsFixture>
{
private Customer_Tests_Fixture Fixture { get; }
private readonly ITestOutputHelper _testOutputHelper;

public Customer_Tests(Customer_Tests_Fixture fixture, ITestOutputHelper testOutputHelper)
{
Fixture = fixture;
_testOutputHelper = testOutputHelper;
}
private CustomerServiceTestsFixture Fixture { get; } = fixture;

[Fact]
public async Task Counts_Customers()
Expand Down Expand Up @@ -50,7 +48,7 @@ public async Task Deletes_Customers()
}
catch (ShopifyException ex)
{
_testOutputHelper.WriteLine($"{nameof(Deletes_Customers)} failed. {ex.Message}");
testOutputHelper.WriteLine($"{nameof(Deletes_Customers)} failed. {ex.Message}");

threw = true;
}
Expand Down Expand Up @@ -169,7 +167,6 @@ public async Task Searches_For_Customers()
}
catch (ShopifyException ex)
{
_testOutputHelper.WriteLine($"{nameof(Searches_For_Customers)} failed. {ex.Message}");

threw = true;
}
Expand Down Expand Up @@ -202,8 +199,6 @@ public async Task Can_Be_Partially_Updated()
public async Task SendInvite_Customers_Default()
{
var created = await Fixture.Create();
long id = created.Id.Value;

var invite = await Fixture.Service.SendInviteAsync(created.Id.Value);

Assert.NotNull(invite);
Expand All @@ -213,8 +208,6 @@ public async Task SendInvite_Customers_Default()
public async Task SendInvite_Customers_Custom()
{
var created = await Fixture.Create();
long id = created.Id.Value;

var options = new CustomerInvite()
{
Subject = "Custom Subject courtesy of ShopifySharp",
Expand All @@ -232,16 +225,14 @@ public async Task SendInvite_Customers_Custom()
public async Task GetAccountActivationUrl_Customers()
{
var created = await Fixture.Create();
long id = created.Id.Value;

var url = await Fixture.Service.GetAccountActivationUrl(created.Id.Value);

Assert.NotEmpty(url);
Assert.Contains("account/activate", url);
}
}

public class Customer_Tests_Fixture : IAsyncLifetime
public class CustomerServiceTestsFixture : IAsyncLifetime
{
public CustomerService Service { get; } = new CustomerService(Utils.MyShopifyUrl, Utils.AccessToken);

Expand Down Expand Up @@ -307,7 +298,11 @@ public async Task<Customer> Create(bool skipAddToCreatedList = false, CustomerCr
VerifiedEmail = true,
Note = Note,
State = "enabled"
}, options);
}, options ?? new CustomerCreateOptions
{
SendEmailInvite = false,
SendWelcomeEmail = false,
});

if (!skipAddToCreatedList)
{
Expand Down

0 comments on commit f540daa

Please sign in to comment.