public void Validate_WhenCalled_ReturnsValidator()
        {
            IDeleteContactGroupCommand sut = CreateSut();

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

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
        public void Validate_WhenContactRepositoryIsNull_ThrowsArgumentNullException()
        {
            IDeleteContactGroupCommand sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("contactRepository"));
        }
        public async Task ExecuteAsync_WhenCalled_AssertDeleteContactGroupAsyncWasCalledOnContactRepository()
        {
            CommandHandler sut = CreateSut();

            int number = _fixture.Create <int>();
            IDeleteContactGroupCommand command = CreateCommandMock(number).Object;
            await sut.ExecuteAsync(command);

            _contactRepositoryMock.Verify(m => m.DeleteContactGroupAsync(It.Is <int>(value => value == number)), Times.Once);
        }
        public void Validate_WhenCalled_AssertShouldBeDeletableWasCalledOnObjectValidator()
        {
            int number = _fixture.Create <int>();
            IDeleteContactGroupCommand sut = CreateSut(number);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeDeletable(
                                                                 It.Is <int>(value => value == number),
                                                                 It.IsNotNull <Func <int, Task <IContactGroup> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "Number") == 0),
                                                                 It.Is <bool>(value => value == false)),
                                                             Times.Once());
        }