/// <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; }
public void TestSetUp() { var container = ContainerFactory.Create(); _householdDataRepository = container.Resolve <IHouseholdDataRepository>(); _householdDataService = container.Resolve <IFoodWasteHouseholdDataService>(); }
public void SetUp() { _fixture = new Fixture(); _householdDataRepositoryMock = MockRepository.GenerateMock <IHouseholdDataRepository>(); _claimValueProviderMock = MockRepository.GenerateMock <IClaimValueProvider>(); _objectMapperMock = MockRepository.GenerateMock <IFoodWasteObjectMapper>(); }
/// <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 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; }
/// <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 the basic functionality which can handle a query for getting some data for 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> protected HouseholdMemberDataGetQueryHandlerBase(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper) { ArgumentNullGuard.NotNull(householdDataRepository, nameof(householdDataRepository)) .NotNull(claimValueProvider, nameof(claimValueProvider)) .NotNull(foodWasteObjectMapper, nameof(foodWasteObjectMapper)); HouseholdDataRepository = householdDataRepository; ClaimValueProvider = claimValueProvider; ObjectMapper = foodWasteObjectMapper; }
public void TestThatHouseholdMemberGetByMailAddressThrowsArgumentNullExceptionWhenMailAddressIsInvalid(string invalidMailAddress) { IHouseholdDataRepository sut = CreateSut(); Assert.That(sut, Is.Not.Null); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.HouseholdMemberGetByMailAddress(invalidMailAddress)); TestHelper.AssertArgumentNullExceptionIsValid(result, "mailAddress"); }
public void TestThatHouseholdMemberGetByMailAddressReturnsNullWhenHouseholdMemberWasNotFoundByFoodWasteDataProvider() { IHouseholdDataRepository sut = CreateSut(new List <HouseholdMemberProxy>(0)); Assert.That(sut, Is.Not.Null); IHouseholdMember result = sut.HouseholdMemberGetByMailAddress(_fixture.Create <string>()); Assert.That(result, Is.Null); }
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 TestThatHouseholdMemberGetByMailAddressThrowsIntranetRepositoryExceptionWhenExceptionOccurs() { Exception exceptionToThrow = _fixture.Create <Exception>(); IHouseholdDataRepository sut = CreateSut(exception: exceptionToThrow); Assert.That(sut, Is.Not.Null); IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.HouseholdMemberGetByMailAddress(_fixture.Create <string>())); TestHelper.AssertIntranetRepositoryExceptionIsValid(result, exceptionToThrow, ExceptionMessage.RepositoryError, "HouseholdMemberGetByMailAddress", exceptionToThrow.Message); }
public void TestThatHouseholdMemberGetByMailAddressThrowsIntranetRepositoryExceptionWhenIntranetRepositoryExceptionOccurs() { IntranetRepositoryException exceptionToThrow = _fixture.Create <IntranetRepositoryException>(); IHouseholdDataRepository sut = CreateSut(exception: exceptionToThrow); Assert.That(sut, Is.Not.Null); IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.HouseholdMemberGetByMailAddress(_fixture.Create <string>())); Assert.That(result, Is.Not.Null); Assert.That(result, Is.EqualTo(exceptionToThrow)); }
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> /// 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; }
public void TestThatHouseholdMemberGetByMailAddressReturnsHouseholdMemberWhenHouseholdMemberWasFoundByFoodWasteDataProvider() { HouseholdMemberProxy householdMemberProxy = new HouseholdMemberProxy(); IHouseholdDataRepository sut = CreateSut(new List <HouseholdMemberProxy> { householdMemberProxy }); Assert.That(sut, Is.Not.Null); IHouseholdMember result = sut.HouseholdMemberGetByMailAddress(_fixture.Create <string>()); Assert.That(result, Is.Not.Null); Assert.That(result, Is.EqualTo(householdMemberProxy)); }
public void TestThatHouseholdMemberGetByMailAddressCallsGetCollectionOnFoodWasteDataProvider() { IHouseholdDataRepository sut = CreateSut(); Assert.That(sut, Is.Not.Null); string mailAddress = _fixture.Create <string>(); sut.HouseholdMemberGetByMailAddress(mailAddress); IDbCommandTestExecutor commandTester = new DbCommandTestBuilder("SELECT HouseholdMemberIdentifier,MailAddress,Membership,MembershipExpireTime,ActivationCode,ActivationTime,PrivacyPolicyAcceptedTime,CreationTime FROM HouseholdMembers WHERE MailAddress=@mailAddress") .AddVarCharDataParameter("@mailAddress", mailAddress, 128) .Build(); _foodWasteDataProviderMock.AssertWasCalled(m => m.GetCollection <HouseholdMemberProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once()); }
/// <summary> /// Creates a query handler which handles the query which can check whether the current user has been created as 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> public HouseholdMemberIsCreatedQueryHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper) { if (householdDataRepository == null) { throw new ArgumentNullException("householdDataRepository"); } if (claimValueProvider == null) { throw new ArgumentNullException("claimValueProvider"); } if (foodWasteObjectMapper == null) { throw new ArgumentNullException("foodWasteObjectMapper"); } _householdDataRepository = householdDataRepository; _claimValueProvider = claimValueProvider; _objectMapper = foodWasteObjectMapper; }
public void TestThatConstructorInitializeHouseholdDataRepository() { IHouseholdDataRepository sut = CreateSut(); Assert.That(sut, Is.Not.Null); }
/// <summary> /// Creates the query handler which handles the query for getting household member data for the current user. /// </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> public HouseholdMemberDataGetQueryHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper) : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper) { }
/// <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 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 the query handler which handles the query for checking whether the current user has accepted the privacy policy. /// </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> public HouseholdMemberHasAcceptedPrivacyPolicyQueryHandler(IHouseholdDataRepository householdDataRepository, IClaimValueProvider claimValueProvider, IFoodWasteObjectMapper foodWasteObjectMapper) : base(householdDataRepository, claimValueProvider, foodWasteObjectMapper) { }