Esempio n. 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;
        }
Esempio n. 2
0
        public Repository_Tests()
        {
            _aggregateRootRepository = The <IAggregateRootRepository <CarState> >();

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

            _carPolicy = The <ICarPolicy>();

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