This file contains hidden or 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
| public class InMemoryProductRepository_Tests : _ProductRepository_Tests | |
| { | |
| protected overrides IProductRepository Create() | |
| { | |
| return new InMemoryProductRepository(); | |
| } | |
| } | |
| public class SqlServerProductRepository_Tests : _ProductRepository_Tests | |
| { |
This file contains hidden or 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
| public abstract class _ProductRepository_Tests | |
| { | |
| private const string PRODUCT_NAME = "Product Name"; | |
| private const string PRODUCT_DESC = "Product Description"; | |
| private readonly IProductRepository _Service; | |
| public _ProductRepository_Tests() | |
| { | |
| _Service = CreateService(); |
This file contains hidden or 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
| public class PhoneNumber | |
| { | |
| private PhoneNumber() { } | |
| public string CountryCode { get; private set; } = ""; | |
| public string AreaCode { get; private set; } = ""; | |
| public string Locale { get; private set; } = ""; | |
| public string Number { get; private set; } = ""; | |
| public static PhoneNumber Parse(string value) |
This file contains hidden or 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
| using Sparcpoint.Inventory.Normalize; | |
| using System; | |
| using Xunit; | |
| namespace Sparcpoint.Inventory.Tests.xUnit | |
| { | |
| public class PhoneNumberParsingTests | |
| { | |
| [Theory] | |
| [InlineData("+12604442268", "+1", "260", "444", "2268")] |
This file contains hidden or 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
| using Sparcpoint.Inventory.Normalize; | |
| using Xunit; | |
| namespace Sparcpoint.Inventory.Tests.xUnit | |
| { | |
| public class PhoneNumberParsingTests | |
| { | |
| [Theory] | |
| [InlineData("12604442268", "1", "260", "444", "2268")] | |
| [InlineData("2604442268", "", "260", "444", "2268")] |
This file contains hidden or 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
| public class PhoneNumber | |
| { | |
| private PhoneNumber() { } | |
| public string CountryCode { get; private set; } = ""; | |
| public string AreaCode { get; private set; } = ""; | |
| public string Locale { get; private set; } = ""; | |
| public string Number { get; private set; } = ""; | |
| public static PhoneNumber Parse(string value) |
This file contains hidden or 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
| public interface IProductRepository | |
| { | |
| Task<Product> Get(int id); | |
| Task<IEnumerable<Product>> GetAll(); | |
| Task<int> Create(Product product); | |
| Task Update(int id, Product product); | |
| Task<IEnumerable<Product>> FindByName(string name); | |
| Task<IEnumerable<Product>> FindBySku(string name); | |
| Task AddSkuToProduct(int id, string sku); | |
| } |
This file contains hidden or 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
| public interface IProductRepository | |
| { | |
| Task<IEnumerable<Product>> Get(params int[] id); | |
| Task<int> Create(Product product); | |
| Task Update(int id, Product product); | |
| Task<IEnumerable<Product>> Find(ProductQuery query); | |
| } | |
| public class ProductQuery | |
| { |
This file contains hidden or 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
| // .NET 5.0 or less | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... Other Services | |
| services | |
| .AddFilterScopedSqlExecutor("...Connection String...") | |
| .AddSqlPerformanceLogging() | |
| .AddSqlExceptionHandling() | |
| ; | |
| } |
This file contains hidden or 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
| public static class ServiceCollectionExtensions | |
| { | |
| public static IServiceCollection AddSqlExceptionHandling(this IServiceCollection services) | |
| => services | |
| .Decorate<ISqlExecutor, HandleExceptionsSqlExecutor>() | |
| ; | |
| } |
NewerOlder