public async Task WhenDoneePending_ThenValidates() { var repo = new Mock <IEntityRepository <TaxStatusValidation> >(); var people = new Mock <IPersonRepository>(); var donee = Constants.Donee.Create(); Assert.Equal(TaxStatus.Unknown, donee.TaxStatus); people.Setup(x => x.GetAsync <Donee>(donee.PersonId, false)) .ReturnsAsync(donee); var handler = new TaxStatusValidationHandler( Mock.Of <ITaxIdRecognizer>(x => x.RecognizeAsync(donee) == Task.FromResult(TaxId.None)), people.Object, repo.Object); var validation = new TaxStatusValidation(Constants.Donee.Id); await handler.ExecuteAsync(validation); Assert.Equal(TaxStatus.Validated, donee.TaxStatus); people.Verify(x => x.PutAsync(donee)); repo.Verify(x => x.DeleteAsync(validation)); }
public async Task WhenDoneeNotFound_ThenDeletesValidation() { var repo = new Mock <IEntityRepository <TaxStatusValidation> >(); var handler = new TaxStatusValidationHandler( Mock.Of <ITaxIdRecognizer>(), Mock.Of <IPersonRepository>(), repo.Object); var validation = new TaxStatusValidation(Constants.Donee.Id); await handler.ExecuteAsync(validation); repo.Verify(x => x.DeleteAsync(validation)); }
public async Task WhenDoneeValidated_ThenDeletesValidationAndStops() { var repo = new Mock <IEntityRepository <TaxStatusValidation> >(); var donee = Constants.Donee.Create(); donee.UpdateTaxStatus(TaxId.None); var handler = new TaxStatusValidationHandler( new Mock <ITaxIdRecognizer>(MockBehavior.Strict).Object, Mock.Of <IPersonRepository>(x => x.GetAsync <Donee>(donee.PersonId, false) == Task.FromResult(donee)), repo.Object); var validation = new TaxStatusValidation(Constants.Donee.Id); await handler.ExecuteAsync(validation); repo.Verify(x => x.DeleteAsync(validation)); }