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 AutoMapperBootstrapper | |
{ | |
private static readonly Lazy<AutoMapperBootstrapper> Bootstrapper = new Lazy<AutoMapperBootstrapper>(InternalInitialize); | |
public static void Initialize() | |
{ | |
var bootstrapper = Bootstrapper.Value; | |
} | |
private AutoMapperBootstrapper() |
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 TestingConvention : Convention | |
{ | |
public TestingConvention() | |
{ | |
Classes | |
.NameEndsWith("Tests"); | |
Methods | |
.Where(method => method.IsVoid() || method.IsAsync()); |
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 ContactEditTests | |
{ | |
... | |
public void ShouldSaveChangesToSelectedContact(Contact contactToEdit, Contact anotherContact) | |
{ | |
Save(contactToEdit, anotherContact); | |
var selectedContactId = contactToEdit.Id; |
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 ContactEditTests | |
{ | |
... | |
public void ShouldRequireMinimumFields() | |
{ | |
new ContactEdit.Command() | |
.ShouldNotValidate("'Name' should not be empty."); | |
} |
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
namespace ContactList.Tests.Features | |
{ | |
using Core.Domain; | |
using ContactList.Features.Contact; | |
using static Testing; | |
using Should; | |
public class ContactEditTests | |
{ | |
public void ShouldDisplaySelectedContact(Contact contactToEdit, Contact anotherContact) |
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
namespace ContactList.Core.Domain | |
{ | |
using System; | |
public abstract class Entity | |
{ | |
public Guid Id { get; set; } | |
} | |
public class Contact : Entity |
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
namespace ContactList.Features.Contact | |
{ | |
using System.Web.Mvc; | |
using MediatR; | |
public class ContactController : Controller | |
{ | |
private readonly IMediator _mediator; | |
public ContactController(IMediator mediator) |
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
namespace ContactList.Features.Contact | |
{ | |
using System; | |
using AutoMapper; | |
using ContactLists.Core; | |
using Core.Domain; | |
using FluentValidation; | |
using MediatR; | |
public class ContactEdit |
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 ContactsContext : DbContext | |
{ | |
private DbContextTransaction _currentTransaction; | |
... | |
public void BeginTransaction() | |
{ | |
if (_currentTransaction != null) | |
return; |
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 UnitOfWork : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
var database = DependencyResolver.Current.GetService<ContactsContext>(); | |
database.BeginTransaction(); | |
} | |
public override void OnActionExecuted(ActionExecutedContext filterContext) |