/// <summary> /// Creates the basic functionality for command handlers which handles commands for household data in the food waste domain. /// </summary> /// <param name="householdDataRepository">Implementation of the repository which can access household data for the food waste domain.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of the common validations.</param> /// <param name="exceptionBuilder">Implementation of the builder which can build exceptions.</param> protected FoodWasteHouseholdDataCommandHandlerBase(IHouseholdDataRepository householdDataRepository, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder) { if (householdDataRepository == null) { throw new ArgumentNullException("householdDataRepository"); } if (foodWasteObjectMapper == null) { throw new ArgumentNullException("foodWasteObjectMapper"); } if (specification == null) { throw new ArgumentNullException("specification"); } if (commonValidations == null) { throw new ArgumentNullException("commonValidations"); } if (exceptionBuilder == null) { throw new ArgumentNullException("exceptionBuilder"); } _householdDataRepository = householdDataRepository; _foodWasteObjectMapper = foodWasteObjectMapper; _specification = specification; _commonValidations = commonValidations; _exceptionBuilder = exceptionBuilder; }
public void SetUp() { _householdDataRepositoryMock = MockRepository.GenerateMock <IHouseholdDataRepository>(); _claimValueProviderMock = MockRepository.GenerateMock <IClaimValueProvider>(); _objectMapperMock = MockRepository.GenerateMock <IFoodWasteObjectMapper>(); _specificationMock = MockRepository.GenerateMock <ISpecification>(); _commonValidationsMock = MockRepository.GenerateMock <ICommonValidations>(); _exceptionBuilderMock = MockRepository.GenerateMock <IExceptionBuilder>(); _fixture = new Fixture(); }
public void SetUp() { _householdDataRepositoryMock = MockRepository.GenerateMock <IHouseholdDataRepository>(); _claimValueProviderMock = MockRepository.GenerateMock <IClaimValueProvider>(); _objectMapperMock = MockRepository.GenerateMock <IFoodWasteObjectMapper>(); _specificationMock = MockRepository.GenerateMock <ISpecification>(); _commonValidationsMock = MockRepository.GenerateMock <ICommonValidations>(); _domainObjectValidationsMock = MockRepository.GenerateMock <IDomainObjectValidations>(); _logicExecutorMock = MockRepository.GenerateMock <ILogicExecutor>(); _exceptionBuilderMock = MockRepository.GenerateMock <IExceptionBuilder>(); _fixture = new Fixture(); _random = new Random(_fixture.Create <int>()); }
/// <summary> /// Danner basisklasse for en CommandHandler til finansstyring. /// </summary> /// <param name="finansstyringRepository">Implementering af repository til finansstyring.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af builderen, der kan bygge exceptions.</param> protected FinansstyringCommandHandlerBase(IFinansstyringRepository finansstyringRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) { if (finansstyringRepository == null) { throw new ArgumentNullException("finansstyringRepository"); } if (objectMapper == null) { throw new ArgumentNullException("objectMapper"); } if (exceptionBuilder == null) { throw new ArgumentNullException("exceptionBuilder"); } _finansstyringRepository = finansstyringRepository; _objectMapper = objectMapper; _exceptionBuilder = exceptionBuilder; }
public static bool TryGetBuilder(Type type, out IExceptionBuilder builder) { builder = default; if (type is null) { return(false); } if (!type.IsSubclassOf(typeof(Exception))) { return(false); } if (!_customExceptionBuilders.TryGetValue(type, out var buildingFunc)) { return(false); } builder = buildingFunc?.Invoke(); return(builder is not null); }
/// <summary> /// Danner basisklasse for en CommandHandler til adressekartoteket. /// </summary> /// <param name="adresseRepository">Implementering af repository til adresser.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param> protected AdressekartotekCommandHandlerBase(IAdresseRepository adresseRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) { if (adresseRepository == null) { throw new ArgumentNullException("adresseRepository"); } if (objectMapper == null) { throw new ArgumentNullException("objectMapper"); } if (exceptionBuilder == null) { throw new ArgumentNullException("exceptionBuilder"); } _adresseRepository = adresseRepository; _objectMapper = objectMapper; _exceptionBuilder = exceptionBuilder; }
/// <summary> /// Danner basisklasse for en CommandHandler til fælles elementer i domænet, såsom brevhoveder. /// </summary> /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param> protected FællesElementCommandHandlerBase(IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) { if (fællesRepository == null) { throw new ArgumentNullException("fællesRepository"); } if (objectMapper == null) { throw new ArgumentNullException("objectMapper"); } if (exceptionBuilder == null) { throw new ArgumentNullException("exceptionBuilder"); } _fællesRepository = fællesRepository; _objectMapper = objectMapper; _exceptionBuilder = exceptionBuilder; }
public static Exception Return(Type type, Dictionary <string, IArgDescriptionVal> exceptionParams, out IExceptionBuilder builder) { if (type is null) { throw new ArgumentNullException(nameof(type)); } if (!type.IsSubclassOf(typeof(Exception))) { throw new ArgumentException($"Type '{type}' does not be divided from {typeof(Exception)}", nameof(type)); } if (exceptionParams is null) { return(CreateAndReturnExceptionWithoutParams(type, out builder)); } CheckExceptionParams(type, exceptionParams, out var needTwoStepCheck); if (!_customExceptionBuilders.TryGetValue(type, out var buildingFunc)) { throw new InvalidOperationException("The construction delegate of the exception type is not registered."); } builder = buildingFunc?.Invoke(); if (builder is null) { throw new InvalidOperationException("The generation of the construction delegate for this exception type failed."); } if (needTwoStepCheck && !(builder.ArgumentsChecker?.Invoke(exceptionParams) ?? true)) { throw new ArgumentException("The construction parameter of the exception type is missing"); } return(builder.Build(exceptionParams)); }
/// <summary> /// Creates the command handler which can handles the command for upgrading the membership on the current users household member account. /// </summary> /// <param name="householdDataRepository">Implementation of a repository which can access household data for the food waste domain.</param> /// <param name="claimValueProvider">Implementation of a provider which can resolve values from the current users claims.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of a common validations.</param> /// <param name="domainObjectValidations">Implementaion of a common validations used by domain objects in the food waste domain.</param> /// <param name="exceptionBuilder">Implementation of a builder which can build exceptions.</param> public HouseholdMemberUpgradeMembershipCommandHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IDomainObjectValidations domainObjectValidations, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { if (domainObjectValidations == null) { throw new ArgumentNullException("domainObjectValidations"); } _domainObjectValidations = domainObjectValidations; }
/// <summary> /// Danner egen klasse til test af basisklasse for en CommandHandler til kalenderdelen under OSWEBDB. /// </summary> /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param> /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param> public MyKalenderCommandHandler(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(kalenderRepository, fællesRepository, objectMapper, exceptionBuilder) { }
/// <summary> /// Creates a command handler which handles a command for importing a food item from a given data provider. /// </summary> /// <param name="systemDataRepository">Implementation of the repository which can access system data for the food waste domain.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of the common validations.</param> /// <param name="exceptionBuilder">Implementation of the builder which can build exceptions.</param> /// <param name="logicExecutor">Implementation of the logic executor which can execute basic logic.</param> public FoodItemImportFromDataProviderCommandHandler(ISystemDataRepository systemDataRepository, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder, ILogicExecutor logicExecutor) : base(systemDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { if (logicExecutor == null) { throw new ArgumentNullException("logicExecutor"); } _logicExecutor = logicExecutor; }
/// <summary> /// Danner basisklasse for en CommandHandler til regnskaber. /// </summary> /// <param name="finansstyringRepository">Implementering af repository til finansstyring.</param> /// <param name="adresseRepository">Implementering af repository til adresser.</param> /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af builderen, der kan bygge exceptions.</param> protected RegnskabCommandHandlerBase(IFinansstyringRepository finansstyringRepository, IAdresseRepository adresseRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(finansstyringRepository, objectMapper, exceptionBuilder) { if (adresseRepository == null) { throw new ArgumentNullException("adresseRepository"); } if (fællesRepository == null) { throw new ArgumentNullException("fællesRepository"); } _adresseRepository = adresseRepository; _fællesRepository = fællesRepository; }
/// <summary> /// Creates an instance of the private class for testing the basic functionality for command handlers which handles commands for household data in the food waste domain. /// </summary> /// <param name="householdDataRepository">Implementation of the repository which can access household data for the food waste domain.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of the common validations.</param> /// <param name="exceptionBuilder">Implementation of the builder which can build exceptions.</param> public MyFoodWasteHouseholdDataCommandHandler(IHouseholdDataRepository householdDataRepository, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { }
/// <summary> /// Creates the basic functionality which can handle a command for modifying some data on a household member. /// </summary> /// <param name="householdDataRepository">Implementation of a repository which can access household data for the food waste domain.</param> /// <param name="claimValueProvider">Implementation of a provider which can resolve values from the current users claims.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of a common validations.</param> /// <param name="exceptionBuilder">Implementation of a builder which can build exceptions.</param> protected HouseholdMemberDataModificationCommandHandlerBase(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { ArgumentNullGuard.NotNull(claimValueProvider, nameof(claimValueProvider)); ClaimValueProvider = claimValueProvider; }
/// <summary> /// Creates a command handler which handles a command for adding a household member to a given household on the current users household account. /// </summary> /// <param name="householdDataRepository">Implementation of a repository which can access household data for the food waste domain.</param> /// <param name="claimValueProvider">Implementation of a provider which can resolve values from the current users claims.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of common validations.</param> /// <param name="domainObjectValidations">Implementation of common validations used by domain objects in the food waste domain.</param> /// <param name="logicExecutor">Implementation of the logic executor which can execute basic logic.</param> /// <param name="exceptionBuilder">Implementation of a builder which can build exceptions.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="domainObjectValidations"/> or <paramref name="logicExecutor"/> is null.</exception> public HouseholdAddHouseholdMemberCommandHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IDomainObjectValidations domainObjectValidations, ILogicExecutor logicExecutor, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { ArgumentNullGuard.NotNull(domainObjectValidations, nameof(domainObjectValidations)) .NotNull(logicExecutor, nameof(logicExecutor)); _domainObjectValidations = domainObjectValidations; _logicExecutor = logicExecutor; }
/// <summary> /// Danner egen klasse til test af basisklasse for en CommandHandler til adressekartoteket. /// </summary> /// <param name="adresseRepository">Implementering af repository til adresser.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param> public MyCommandHandler(IAdresseRepository adresseRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(adresseRepository, objectMapper, exceptionBuilder) { }
public static bool TryGetBuilder <TException>(out IExceptionBuilder builder) where TException : Exception { return(TryGetBuilder(typeof(TException), out builder)); }
/// <summary> /// Danner egen klasse til test af basisklasse for en CommandHandler til regnskaber. /// </summary> /// <param name="finansstyringRepository">Implementering af repository til finansstyring.</param> /// <param name="adresseRepository">Implementering af repository til adresser.</param> /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af builderen, der kan bygge exceptions.</param> public MyCommandHandler(IFinansstyringRepository finansstyringRepository, IAdresseRepository adresseRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(finansstyringRepository, adresseRepository, fællesRepository, objectMapper, exceptionBuilder) { }
/// <summary> /// Danner CommandHandler til håndtering af kommandoen: BogføringslinjeOpretCommand. /// </summary> /// <param name="finansstyringRepository">Implementering af repository til finansstyring.</param> /// <param name="adresseRepository">Implementering af repository til adressekartoteket.</param> /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet.</param> /// <param name="konfigurationRepository">Implementering af konfigurationsrepository.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af builderen, der kan bygge exceptions.</param> public BogføringslinjeOpretCommandHandler(IFinansstyringRepository finansstyringRepository, IAdresseRepository adresseRepository, IFællesRepository fællesRepository, IKonfigurationRepository konfigurationRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(finansstyringRepository, adresseRepository, fællesRepository, objectMapper, exceptionBuilder) { if (konfigurationRepository == null) { throw new ArgumentNullException("konfigurationRepository"); } _konfigurationRepository = konfigurationRepository; }
/// <summary> /// Danner egen klasse til test af basisklasse for en CommandHandler til fælles elementer i domænet, såsom brevhoveder. /// </summary> /// <param name="fællesRepository">Implementering af repository til finansstyring.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param> public MyCommandHandler(IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(fællesRepository, objectMapper, exceptionBuilder) { }
/// <summary> /// Dannere egen klasse til test af basisklasse for en CommandHandler til finansstyring. /// </summary> /// <param name="finansstyringRepository">Implementering af repository til finansstyring.</param> /// <param name="objectMapper">Implementering af objectmapper.</param> /// <param name="exceptionBuilder">Implementering af builderen, der kan bygge exceptions.</param> public MyCommandHandler(IFinansstyringRepository finansstyringRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder) : base(finansstyringRepository, objectMapper, exceptionBuilder) { }
/// <summary> /// Creates a command handler which handles a command for adding a household to the current users household account. /// </summary> /// <param name="householdDataRepository">Implementation of a repository which can access household data for the food waste domain.</param> /// <param name="claimValueProvider">Implementation of a provider which can resolve values from the current users claims.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of a common validations.</param> /// <param name="logicExecutor">Implementation of the logic executor which can execute basic logic.</param> /// <param name="exceptionBuilder">Implementation of a builder which can build exceptions.</param> public HouseholdAddCommandHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, ILogicExecutor logicExecutor, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { if (claimValueProvider == null) { throw new ArgumentNullException("claimValueProvider"); } if (logicExecutor == null) { throw new ArgumentNullException("logicExecutor"); } _claimValueProvider = claimValueProvider; _logicExecutor = logicExecutor; }
public static TException Return <TException>(Dictionary <string, IArgDescriptionVal> exceptionParams, out IExceptionBuilder builder) where TException : Exception { return(Return(typeof(TException), exceptionParams, out builder) as TException); }
/// <summary> /// Creates a command handler which handles a command for modifying a foreign key. /// </summary> /// <param name="systemDataRepository">Implementation of the repository which can access system data for the food waste domain.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of the common validations.</param> /// <param name="exceptionBuilder">Implementation of the builder which can build exceptions.</param> public ForeignKeyModifyCommandHandler(ISystemDataRepository systemDataRepository, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder) : base(systemDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { }
private static Exception CreateAndReturnExceptionWithoutParams(Type type, out IExceptionBuilder builder) { builder = ExceptionBuilder.Create(type); return(builder.Build()); }
/// <summary> /// Creates a command handler which handles a command for updating a household to the current users household account. /// </summary> /// <param name="householdDataRepository">Implementation of a repository which can access household data for the food waste domain.</param> /// <param name="claimValueProvider">Implementation of a provider which can resolve values from the current users claims.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of a common validations.</param> /// <param name="exceptionBuilder">Implementation of a builder which can build exceptions.</param> public HouseholdUpdateCommandHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { }
/// <summary> /// Creates a command handler which handles a command for adding a household member. /// </summary> /// <param name="householdDataRepository">Implementation of the repository which can access household data for the food waste domain.</param> /// <param name="foodWasteObjectMapper">Implementation of an object mapper which can map objects in the food waste domain.</param> /// <param name="specification">Implementation of a specification which encapsulates validation rules.</param> /// <param name="commonValidations">Implementation of the common validations.</param> /// <param name="domainObjectValidations">Implementation of the common validations used by domain objects in the food waste domain.</param> /// <param name="welcomeLetterDispatcher">Implementation of the dispatcher which can dispatch the welcome letter to a household member.</param> /// <param name="exceptionBuilder">Implementation of the builder which can build exceptions.</param> public HouseholdMemberAddCommandHandler(IHouseholdDataRepository householdDataRepository, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IDomainObjectValidations domainObjectValidations, IWelcomeLetterDispatcher welcomeLetterDispatcher, IExceptionBuilder exceptionBuilder) : base(householdDataRepository, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder) { if (domainObjectValidations == null) { throw new ArgumentNullException("domainObjectValidations"); } if (welcomeLetterDispatcher == null) { throw new ArgumentNullException("welcomeLetterDispatcher"); } _domainObjectValidations = domainObjectValidations; _welcomeLetterDispatcher = welcomeLetterDispatcher; }