public Domain_Tests() { var moqCarPolicy = new Mock <ICarPolicy>(); moqCarPolicy.Setup(p => p.Apply(It.Is <ModelYearCannotBeAboveThan>(m => m.ModelYear > 2019))) .Throws <Exception>(); _carPolicy = moqCarPolicy.Object; }
public Repository_Tests() { _aggregateRootRepository = The <IAggregateRootRepository <CarState> >(); _fakeCarId = Guid.NewGuid().ToString(); _carPolicy = The <ICarPolicy>(); SeedCar().ConfigureAwait(false) .GetAwaiter().GetResult(); }
public AddItemToCarCommandHandler(ICarPolicy carPolicy, IUnitOfWork unitOfWork, IAggregateRootRepository <CarState> rootRepository) : base(unitOfWork, rootRepository) =>
public ChangeModelYearCommandHandler(ICarPolicy carPolicy, IUnitOfWork unitOfWork, IAggregateRootRepository <CarState> rootRepository) : base(unitOfWork, rootRepository) =>
public static CarState.Result AddCarItem(CarState state, CarItemId carItemId, string desc, ICarPolicy carPolicy) => state.With(s => carPolicy.Apply(new CannotBeAddedMoreThanTwoItems(s))) .ApplyEvent(new CarItemAddedEvent(state.Id, carItemId, desc));
public static CarState.Result RenewModel(CarState state, int year, ICarPolicy carPolicy) => state.With(s => carPolicy.Apply(new ModelYearCannotBeAboveThan(year))) .ApplyEvent(new CarModelRenewedEvent(state.Id, year));