Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/Mailtrap.Example.Contact/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
IContactCollectionResource contactsResource = accountResource.Contacts();

// Get all contacts for account
IList<Contact> contacts = await contactsResource.GetAll();
// TODO: Enable when GetAll is implemented
IList<Contact> contacts = /*await contactsResource.GetAll()*/ [];

Contact? contact = contacts
.FirstOrDefault(p => string.Equals(p.Email, contactEmail, StringComparison.OrdinalIgnoreCase));
Expand Down
3 changes: 2 additions & 1 deletion examples/Mailtrap.Example.ContactEvents/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
IContactCollectionResource contactsResource = accountResource.Contacts();

// Get all contacts for account
IList<Contact> contacts = await contactsResource.GetAll();
// TODO: Enable when GetAll is implemented
IList<Contact> contacts = /*await contactsResource.GetAll()*/ [];

Contact? contact = contacts.Count > 0 ? contacts[0] : null;
if (contact is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,6 @@ public interface IContactCollectionResource : IRestResource
/// </returns>
public IContactEventCollectionResource Events(string contactId);

/// <summary>
/// Gets collection of contact details.
/// </summary>
///
/// <param name="cancellationToken">
/// Token to control operation cancellation.
/// </param>
///
/// <returns>
/// Collection of contact details.
/// </returns>
public Task<IList<Contact>> GetAll(CancellationToken cancellationToken = default);

/// <summary>
/// Creates a new contact with details specified by <paramref name="request"/>.
/// </summary>
Expand All @@ -118,7 +105,7 @@ public interface IContactCollectionResource : IRestResource
/// </param>
///
/// <param name="cancellationToken">
/// <inheritdoc cref="GetAll(CancellationToken)" path="/param[@name='cancellationToken']"/>
/// Token to control operation cancellation.
/// </param>
///
/// <returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@ public ContactsIntegrationTests()
_jsonSerializerOptions = _clientConfig.ToJsonSerializerOptions();
}


[Test]
public async Task GetAll_Success()
{
// Arrange
var httpMethod = HttpMethod.Get;
var requestUri = _resourceUri.AbsoluteUri;

using var responseContent = await Feature.LoadFileToStringContent();

using var mockHttp = new MockHttpMessageHandler();
mockHttp
.Expect(httpMethod, requestUri)
.WithHeaders("Authorization", $"Bearer {_clientConfig.ApiToken}")
.WithHeaders("Accept", MimeTypes.Application.Json)
.WithHeaders("User-Agent", HeaderValues.UserAgent.ToString())
.Respond(HttpStatusCode.OK, responseContent);

var serviceCollection = new ServiceCollection();
serviceCollection
.AddMailtrapClient(_clientConfig)
.ConfigurePrimaryHttpMessageHandler(() => mockHttp);

using var services = serviceCollection.BuildServiceProvider();
var client = services.GetRequiredService<IMailtrapClient>();

// Act
var result = await client
.Account(_accountId)
.Contacts()
.GetAll()
.ConfigureAwait(false);

// Assert
mockHttp.VerifyNoOutstandingExpectation();

result.Should()
.NotBeNull().And
.HaveCount(3);
}
// TODO: Enable when GetAll is implemented
// [Test]
// public async Task GetAll_Success()
// {
// // Arrange
// var httpMethod = HttpMethod.Get;
// var requestUri = _resourceUri.AbsoluteUri;

// using var responseContent = await Feature.LoadFileToStringContent();

// using var mockHttp = new MockHttpMessageHandler();
// mockHttp
// .Expect(httpMethod, requestUri)
// .WithHeaders("Authorization", $"Bearer {_clientConfig.ApiToken}")
// .WithHeaders("Accept", MimeTypes.Application.Json)
// .WithHeaders("User-Agent", HeaderValues.UserAgent.ToString())
// .Respond(HttpStatusCode.OK, responseContent);

// var serviceCollection = new ServiceCollection();
// serviceCollection
// .AddMailtrapClient(_clientConfig)
// .ConfigurePrimaryHttpMessageHandler(() => mockHttp);

// using var services = serviceCollection.BuildServiceProvider();
// var client = services.GetRequiredService<IMailtrapClient>();

// // Act
// var result = await client
// .Account(_accountId)
// .Contacts()
// .GetAll()
// .ConfigureAwait(false);

// // Assert
// mockHttp.VerifyNoOutstandingExpectation();

// result.Should()
// .NotBeNull().And
// .HaveCount(3);
// }

[Test]
public async Task Create_Success()
Expand Down