This file contains 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 void Configure( | |
IApplicationBuilder app, | |
IHostingEnvironment env) | |
{ | |
app.UseHealthChecks("/health/status", | |
new HealthCheckOptions | |
{ | |
ResponseWriter = async (httpContext, healthReport) => | |
{ | |
var healthReportJson = JsonConvert.SerializeObject(healthReport); |
This file contains 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 IRepository | |
{ | |
void Add(T entity); | |
void Update(Guid id, T updatedEntity); | |
void Delete(Guid id); | |
IEnumerable Get(Expression<Func<T, bool>> predicate); |
This file contains 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 PeriodRepository : IPeriodRepository | |
{ | |
// at this point, I have already created my DbContext which I will | |
// then use to generate the database by running EF Code First commands | |
private PeriodContext context; | |
public PeriodRepository(PeriodContext context) | |
{ | |
this.context = context; | |
} |
This file contains 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 IPeriodRepository : IRepository | |
{ | |
// any aggregate specific queries and commands can | |
// be declared here. | |
} |
This file contains 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
// type restricted to operate only on IDomainObject reference types | |
public class GenericRepository : IRepository where T : class, IDomainObject | |
{ | |
private DbContext context; | |
public GenericSqlRepository(DbContext context) | |
{ | |
this.context = context; | |
} |
This file contains 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 IRepository | |
{ | |
Task GetOneAsync(Guid id); | |
Task<IEnumerable<TDomainObject>> GetListAsync( | |
Expression<Func<TDomainObject,bool>> predicate); | |
Task AddAsync(TDomainObject domainObject); | |
Task UpdateAsync(TDomainObject updatedEntity); |
This file contains 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
internal class StubPublisher : IPublishProductInformation | |
{ | |
public Dictionary<int, Product> PublishedProducts = new Dictionary<int, Product>(); | |
public async Task Publish(Product productInformation) | |
{ | |
PublishedProducts.Add(productInformation.ProductId, | |
productInformation); | |
await Task.CompletedTask; | |
} |
This file contains 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 WhenRunningProductReorderLevelUseCase | |
{ | |
[Fact] | |
public async Task Given_Products_With_Values_When_UseCase_Is_Executed_Then_The_Calculated_ReorderLevel_Is_As_Expected() | |
{ | |
var testProducts = TestData.SampleProductsWithExpectedReorderLevels(); | |
var publisherStub = new StubPublisher(); | |
var activeProductsStub = new StubRetrieveActiveProducts( | |
testProducts.Select(x => x.OriginalProduct).ToList()); | |
var useCase = new UseCase(publisherStub, activeProductsStub); |
This file contains 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
namespace Domain | |
{ | |
public class UseCase | |
{ | |
private readonly IPublisher _publisher; | |
private readonly IRetrieveProducts _productsRetriever; | |
public UseCase( | |
IPublisher publisher, | |
IRetrieveProducts productsRetriever) |
This file contains 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
namespace Domain | |
{ | |
public class UseCase | |
{ | |
private readonly IAdditionalDataA _serviceA; | |
private readonly IProductService _serviceB; | |
private readonly IAdditionalDataC _serviceC; | |
private readonly IAdditionalDataD _serviceD; | |
private readonly IAdditionalDataE _serviceE; | |
private readonly IAdditionalDataF _serviceF; |