Пример #1
0
        public void TestSetUp()
        {
            IContainer container = ContainerFactory.Create();

            _logicExecutor           = container.Resolve <ILogicExecutor>();
            _householdDataRepository = container.Resolve <IHouseholdDataRepository>();
            _householdDataService    = container.Resolve <IFoodWasteHouseholdDataService>();
        }
Пример #2
0
        /// <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;
        }
Пример #3
0
 /// <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;
 }
Пример #4
0
 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>
 /// 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;
 }
        /// <summary>
        /// Imports a given translation on a given translatable domain object.
        /// </summary>
        /// <param name="domainObject">Translatable domain object on which to import the translation.</param>
        /// <param name="translationInfo">Translation informations for the translation to import.</param>
        /// <param name="translationValue">The translation value for the translatable domain object.</param>
        /// <param name="logicExecutor">Implementation of the logic executor which can execute basic logic.</param>
        /// <returns>The imported translation.</returns>
        protected virtual ITranslation ImportTranslation(ITranslatable domainObject, ITranslationInfo translationInfo, string translationValue, ILogicExecutor logicExecutor)
        {
            if (domainObject == null)
            {
                throw new ArgumentNullException("domainObject");
            }
            if (translationInfo == null)
            {
                throw new ArgumentNullException("translationInfo");
            }
            if (string.IsNullOrEmpty(translationValue))
            {
                throw new ArgumentNullException("translationValue");
            }
            if (logicExecutor == null)
            {
                throw new ArgumentNullException("logicExecutor");
            }
            var domainObjectIdentifier    = domainObject.Identifier.HasValue ? domainObject.Identifier.Value : default(Guid);
            var translationInfoIdentifier = translationInfo.Identifier.HasValue ? translationInfo.Identifier.Value : default(Guid);
            var translation = domainObject.Translations.SingleOrDefault(m => m.TranslationOfIdentifier == domainObjectIdentifier && m.TranslationInfo.Identifier.HasValue && m.TranslationInfo.Identifier.Value == translationInfoIdentifier);

            if (translation == null)
            {
                var insertedTranslation = new Translation(domainObjectIdentifier, translationInfo, translationValue);
                insertedTranslation.Identifier = logicExecutor.TranslationAdd(insertedTranslation);
                domainObject.TranslationAdd(insertedTranslation);
                return(insertedTranslation);
            }
            translation.Value      = translationValue;
            translation.Identifier = logicExecutor.TranslationModify(translation);
            return(translation);
        }
Пример #7
0
 /// <summary>
 /// Imports a given translation on a given translatable domain object.
 /// </summary>
 /// <param name="domainObject">Translatable domain object on which to import the translation.</param>
 /// <param name="translationInfo">Translation informations for the translation to import.</param>
 /// <param name="translationValue">The translation value for the translatable domain object.</param>
 /// <param name="logicExecutor">Implementation of the logic executor which can execute basic logic.</param>
 /// <returns>The imported translation.</returns>
 public new ITranslation ImportTranslation(ITranslatable domainObject, ITranslationInfo translationInfo, string translationValue, ILogicExecutor logicExecutor)
 {
     return(base.ImportTranslation(domainObject, translationInfo, translationValue, logicExecutor));
 }