/// <summary>
        /// Creates a command handler which handles a command for removing a household member from 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="exceptionBuilder">Implementation of a builder which can build exceptions.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="domainObjectValidations"/> is null.</exception>
        public HouseholdRemoveHouseholdMemberCommandHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper, ISpecification specification, ICommonValidations commonValidations, IDomainObjectValidations domainObjectValidations, IExceptionBuilder exceptionBuilder)
            : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper, specification, commonValidations, exceptionBuilder)
        {
            ArgumentNullGuard.NotNull(domainObjectValidations, nameof(domainObjectValidations));

            _domainObjectValidations = domainObjectValidations;
        }
예제 #2
0
        public void TestThatCreateInitializeDomainObjectValidations()
        {
            IDomainObjectValidations domainObjectValidations = DomainObjectValidations.Create();

            Assert.That(domainObjectValidations, Is.Not.Null);
            Assert.That(domainObjectValidations, Is.TypeOf <DomainObjectValidations>());
        }
 /// <summary>
 /// Creates a instance of common validations used by domain objects in the food waste domain.
 /// </summary>
 /// <returns>Instance of common validations used by domain objects in the food waste domain.</returns>
 public static IDomainObjectValidations Create()
 {
     lock (SyncRoot)
     {
         return(_domainObjectValidations ?? (_domainObjectValidations = new DomainObjectValidations()));
     }
 }
예제 #4
0
 /// <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>
        /// Creates a household.
        /// </summary>
        /// <param name="name">Name for the household.</param>
        /// <param name="description">Description for the household.</param>
        /// <param name="creationTime">Date and time for when the household was created.</param>
        /// <param name="domainObjectValidations">Implementation for common validations used by domain objects in the food waste domain.</param>
        protected Household(string name, string description, DateTime creationTime, IDomainObjectValidations domainObjectValidations = null)
        {
            ArgumentNullGuard.NotNullOrWhiteSpace(name, nameof(name));

            _name         = name;
            _description  = description;
            _creationTime = creationTime;

            _domainObjectValidations = domainObjectValidations ?? DomainObjectValidations.Create();
        }
 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>();
     _exceptionBuilderMock        = MockRepository.GenerateMock <IExceptionBuilder>();
     _fixture = new Fixture();
     _random  = new Random(_fixture.Create <int>());
 }
예제 #7
0
 /// <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;
 }
예제 #8
0
        /// <summary>
        /// Creates a storage
        /// </summary>
        /// <param name="household">Household where the storage are placed.</param>
        /// <param name="sortOrder">Sort order for the storage.</param>
        /// <param name="storageType">Storage type for the storage.</param>
        /// <param name="description">Description for the storage.</param>
        /// <param name="temperature">Temperature for the storage.</param>
        /// <param name="creationTime">Creation date and time for when the storage was created.</param>
        /// <param name="domainObjectValidations">Implementation of the common validations used by domain objects in the food waste domain.</param>
        protected Storage(IHousehold household, int sortOrder, IStorageType storageType, string description, int temperature, DateTime creationTime, IDomainObjectValidations domainObjectValidations)
        {
            ArgumentNullGuard.NotNull(household, nameof(household))
            .NotNull(storageType, nameof(storageType))
            .NotNull(domainObjectValidations, nameof(domainObjectValidations));

            _domainObjectValidations = domainObjectValidations;

            _household    = household;
            _sortOrder    = ValidateSortOrder(sortOrder, nameof(sortOrder));
            _storageType  = storageType;
            _description  = description;
            _temperature  = ValidateTemperature(temperature, nameof(temperature));
            _creationTime = creationTime;
        }
        /// <summary>
        /// Creates a household member.
        /// </summary>
        /// <param name="mailAddress">Mail address for the household member.</param>
        /// <param name="membership">Membership.</param>
        /// <param name="membershipExpireTime">Date and time for when the membership expires.</param>
        /// <param name="activationCode">Activation code for the household member.</param>
        /// <param name="creationTime">Date and time for when the household member was created.</param>
        /// <param name="domainObjectValidations">Implementation for common validations used by domain objects in the food waste domain.</param>
        protected HouseholdMember(string mailAddress, Membership membership, DateTime?membershipExpireTime, string activationCode, DateTime creationTime, IDomainObjectValidations domainObjectValidations = null)
        {
            ArgumentNullGuard.NotNullOrWhiteSpace(mailAddress, nameof(mailAddress))
            .NotNullOrWhiteSpace(activationCode, nameof(activationCode));

            _domainObjectValidations = domainObjectValidations ?? DomainObjectValidations.Create();
            if (_domainObjectValidations.IsMailAddress(mailAddress) == false)
            {
                throw new IntranetSystemException(Resource.GetExceptionMessage(ExceptionMessage.IllegalValue, mailAddress, "mailAddress"));
            }
            _mailAddress = mailAddress;

            _membership           = membership;
            _membershipExpireTime = membershipExpireTime;
            _activationCode       = activationCode;
            _creationTime         = creationTime;
        }
 /// <summary>
 /// Creates an instance of the private class for testing the storage.
 /// </summary>
 /// <param name="household">Household where the storage are placed.</param>
 /// <param name="sortOrder">Sort order for the storage.</param>
 /// <param name="storageType">Storage type for the storage.</param>
 /// <param name="description">Description for the storage.</param>
 /// <param name="temperature">Temperature for the storage.</param>
 /// <param name="creationTime">Creation date and time for when the storage was created.</param>
 /// <param name="domainObjectValidations">Implementation of the common validations used by domain objects in the food waste domain.</param>
 public MyStorage(IHousehold household, int sortOrder, IStorageType storageType, string description, int temperature, DateTime creationTime, IDomainObjectValidations domainObjectValidations)
     : base(household, sortOrder, storageType, description, temperature, creationTime, domainObjectValidations)
 {
 }
 /// <summary>
 /// Creates a household member.
 /// </summary>
 protected HouseholdMember()
 {
     _domainObjectValidations = DomainObjectValidations.Create();
 }
 /// <summary>
 /// Creates a household member.
 /// </summary>
 /// <param name="mailAddress">Mail address for the household member.</param>
 /// <param name="domainObjectValidations">Implementation for common validations used by domain objects in the food waste domain.</param>
 public HouseholdMember(string mailAddress, IDomainObjectValidations domainObjectValidations = null)
     : this(mailAddress, Membership.Basic, null, GenerateActivationCode(), DateTime.Now, domainObjectValidations)
 {
 }
 /// <summary>
 /// Creates a household.
 /// </summary>
 /// <param name="name">Name for the household.</param>
 /// <param name="description">Description for the household.</param>
 /// <param name="domainObjectValidations">Implementation for common validations used by domain objects in the food waste domain.</param>
 public Household(string name, string description = null, IDomainObjectValidations domainObjectValidations = null)
     : this(name, description, DateTime.Now, domainObjectValidations)
 {
 }
예제 #14
0
 /// <summary>
 /// Creates a storage.
 /// </summary>
 protected Storage()
 {
     _domainObjectValidations = DomainObjectValidations.Create();
 }