public CountriesController(IGetCountriesCommand getCountries, IGetCountryCommand getCountry, IAddCountryCommand addCountry, IEditCountryCommand editCountry, IDeleteCountryCommand deleteCountry)
 {
     this.getCountries  = getCountries;
     this.getCountry    = getCountry;
     this.addCountry    = addCountry;
     this.editCountry   = editCountry;
     this.deleteCountry = deleteCountry;
 }
示例#2
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IDeleteCountryCommand sut = CreateSut();

            IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object);

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
示例#3
0
        public void Validate_WhenContactRepositoryIsNull_ThrowsArgumentNullException()
        {
            IDeleteCountryCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null));

            Assert.That(result.ParamName, Is.EqualTo("contactRepository"));
        }
 public CountriesController(IGetCountriesCommand getCountries, IGetCountryCommand getCountry, IAddCountryCommand addCountry, IEditCountryCommand editCountry, IDeleteCountryCommand deleteCountry, UseCaseExecutor executor)
 {
     this.getCountries  = getCountries;
     this.getCountry    = getCountry;
     this.addCountry    = addCountry;
     this.editCountry   = editCountry;
     this.deleteCountry = deleteCountry;
     this.executor      = executor;
 }
示例#5
0
        public async Task ExecuteAsync_WhenCalled_AssertDeleteCountryAsyncWasCalledOnContactRepository()
        {
            CommandHandler sut = CreateSut();

            string countryCode            = _fixture.Create <string>();
            IDeleteCountryCommand command = CreateCommandMock(countryCode).Object;
            await sut.ExecuteAsync(command);

            _contactRepositoryMock.Verify(m => m.DeleteCountryAsync(It.Is <string>(value => string.CompareOrdinal(value, countryCode) == 0)), Times.Once);
        }
示例#6
0
        public void Validate_WhenCalled_AssertShouldBeDeletableWasCalledOnObjectValidator()
        {
            string countryCode        = _fixture.Create <string>();
            IDeleteCountryCommand sut = CreateSut(countryCode);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object);

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeDeletable(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, countryCode.ToUpper()) == 0),
                                                                 It.IsNotNull <Func <string, Task <ICountry> > >(),
                                                                 It.Is <Type>(value => sut.GetType() == value),
                                                                 It.Is <string>(value => string.Compare(value, "CountryCode", StringComparison.Ordinal) == 0),
                                                                 It.Is <bool>(value => value == false)),
                                                             Times.Once());
        }
 public IActionResult Delete(int id, [FromServices] IDeleteCountryCommand command)
 {
     executor.ExecuteCommand(command, id);
     return(StatusCode(StatusCodes.Status204NoContent));
 }
 public IActionResult Delete(int id, [FromServices] IDeleteCountryCommand command)
 {
     _executor.ExecuteCommand(command, id);
     return(NoContent());
 }
示例#9
0
 public Task <IActionResult> Delete(
     [FromServices] IDeleteCountryCommand command,
     int countryId,
     CancellationToken cancellationToken) => command.ExecuteAsync(countryId, cancellationToken);