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 ContactList.Features.Contact | |
{ | |
using System; | |
using AutoMapper; | |
using ContactLists.Core; | |
using Core.Domain; | |
using FluentValidation; | |
using MediatR; | |
public class ContactEdit |
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
using System.Linq; | |
using ContactList.Core.Domain; | |
using ContactList.Tests; | |
using static Testing; | |
public class EntityTests | |
{ | |
[AllEntities] | |
public void ShouldPersist<TEntity>(TEntity entity) where TEntity : Entity | |
{ |
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 static class Testing | |
{ | |
private static IContainer Container => TestDependencyScope.CurrentNestedContainer; | |
public static T Resolve<T>() | |
{ | |
return Container.GetInstance<T>(); | |
} | |
public static object Resolve(Type type) |
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 AutoFixtureParameterSource : ParameterSource | |
{ | |
public IEnumerable<object[]> GetParameters(MethodInfo method) | |
{ | |
// Produces a randomly-populated object for each | |
// parameter declared on the test method, using | |
// a Fixture that has our customizations. | |
var fixture = new Fixture(); |
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 NestedContainerPerCase : CaseBehavior | |
{ | |
public void Execute(Case context, Action next) | |
{ | |
TestDependencyScope.Begin(); | |
next(); | |
TestDependencyScope.End(); | |
} | |
} |
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 static class IoC | |
{ | |
private static readonly Lazy<IContainer> Bootstrapper = new Lazy<IContainer>(Initialize, true); | |
public static IContainer Container => Bootstrapper.Value; | |
private static IContainer Initialize() | |
{ | |
return new Container(cfg => | |
{ |
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 ResetDatabase : CaseBehavior | |
{ | |
public void Execute(Case context, Action next) | |
{ | |
var checkpoint = new Checkpoint | |
{ | |
SchemasToExclude = new[] { "RoundhousE" }, | |
TablesToIgnore = new[] { "sysdiagrams" } | |
}; |
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 InitializeAutoMapper : ClassBehavior | |
{ | |
public void Execute(Class context, Action next) | |
{ | |
AutoMapperBootstrapper.Initialize(); | |
next(); | |
} | |
} |
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 AutoMapperBootstrapper | |
{ | |
private static readonly Lazy<AutoMapperBootstrapper> Bootstrapper = new Lazy<AutoMapperBootstrapper>(InternalInitialize); | |
public static void Initialize() | |
{ | |
var bootstrapper = Bootstrapper.Value; | |
} | |
private AutoMapperBootstrapper() |
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 TestingConvention : Convention | |
{ | |
public TestingConvention() | |
{ | |
Classes | |
.NameEndsWith("Tests"); | |
Methods | |
.Where(method => method.IsVoid() || method.IsAsync()); |