Skip to content

Instantly share code, notes, and snippets.

Patrick Lioi plioi

  • Austin, TX
Block or report user

Report or block plioi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TestingConvention.cs
public class TestingConvention : Convention
{
public TestingConvention()
{
Classes
.NameEndsWith("Tests");
Methods
.Where(method => method.IsVoid() || method.IsAsync());
View ContactEditTests.cs
public class ContactEditTests
{
...
public void ShouldSaveChangesToSelectedContact(Contact contactToEdit, Contact anotherContact)
{
Save(contactToEdit, anotherContact);
var selectedContactId = contactToEdit.Id;
View ContactEditTests.cs
public class ContactEditTests
{
...
public void ShouldRequireMinimumFields()
{
new ContactEdit.Command()
.ShouldNotValidate("'Name' should not be empty.");
}
View ContactEditTests.cs
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)
View Domain.cs
namespace ContactList.Core.Domain
{
using System;
public abstract class Entity
{
public Guid Id { get; set; }
}
public class Contact : Entity
View ContactController.cs
namespace ContactList.Features.Contact
{
using System.Web.Mvc;
using MediatR;
public class ContactController : Controller
{
private readonly IMediator _mediator;
public ContactController(IMediator mediator)
View ContactEdit.cs
namespace ContactList.Features.Contact
{
using System;
using AutoMapper;
using ContactLists.Core;
using Core.Domain;
using FluentValidation;
using MediatR;
public class ContactEdit
View ContactsContext.cs
public class ContactsContext : DbContext
{
private DbContextTransaction _currentTransaction;
...
public void BeginTransaction()
{
if (_currentTransaction != null)
return;
View UnitOfWork.cs
public class UnitOfWork : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var database = DependencyResolver.Current.GetService<ContactsContext>();
database.BeginTransaction();
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
View Assertions.cs
using System;
using System.Linq;
using MediatR;
using Should;
using static Testing;
public static class Assertions
{
public static void ShouldValidate<TResponse>(this IRequest<TResponse> message)
{
You can’t perform that action at this time.