Skip to content

Instantly share code, notes, and snippets.

View ByteDev's full-sized avatar
:octocat:

ByteDev

:octocat:
View GitHub Profile
using System;
using System.Runtime.Serialization;

// ...

[Serializable]
public class EntityNotFoundException : Exception
{
 private const string DefaultMessage = "Entity does not exist.";
using System;
using System.Runtime.Serialization;

// ...

[Serializable]
public class EntityNotFoundException : Exception
{
    private const string DefaultMessage = "Entity does not exist.";
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;

// ...

[TestFixture]
public class EntityNotFoundExceptionTests
using System;
using System.Text.Json;
using System.Text.Json.Serialization;

// ...

public class UnixEpochTimeToDateTimeJsonConverter : JsonConverter<DateTime>
{
 public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
using System;
using System.Text.Json;
using NUnit.Framework;

// ...

public class TestEntity
{
    [JsonPropertyName("datetime")]
{
  "message": "Resource not found." 
}
{
  "messages": [{
 "code": "2001",
{
  "errors": {
    "customer": [
      "The customer field is required.",
      "The customer field should be uppercase."
    ],
    "orders": [
      "The orders field is required."
 ]
public interface ICustomerApiClient
{
    Task<SearchCustomerResponse> SearchAsync(SearchCustomerRequest request, CancellationToken cancellationToken = default);
}

// ...

public class CustomerApiClient : ICustomerApiClient
{
public async Task<SearchCustomerResponse> SearchAsync(SearchCustomerRequest request, CancellationToken cancellationToken = default)
{
    // make the call to the API and handle the response
    // making sure to pass in the cancellationToken to any async method
}
using System.Text.Json.Serialization;

// ...

public class AddressRequest
{
    [JsonPropertyName("addressId")]
    public int Id { get; set; }