예제 #1
0
        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;
        }
예제 #2
0
        public Repository_Tests()
        {
            _aggregateRootRepository = The <IAggregateRootRepository <CarState> >();

            _fakeCarId = Guid.NewGuid().ToString();

            _carPolicy = The <ICarPolicy>();

            SeedCar().ConfigureAwait(false)
            .GetAwaiter().GetResult();
        }
예제 #3
0
 public AddItemToCarCommandHandler(ICarPolicy carPolicy,
                                   IUnitOfWork unitOfWork,
                                   IAggregateRootRepository <CarState> rootRepository)
     : base(unitOfWork, rootRepository) =>
예제 #4
0
 public ChangeModelYearCommandHandler(ICarPolicy carPolicy,
                                      IUnitOfWork unitOfWork,
                                      IAggregateRootRepository <CarState> rootRepository)
     : base(unitOfWork, rootRepository) =>
예제 #5
0
 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));
예제 #6
0
 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));