public void Arrange() { _expectedEmployers = new List <Employer> { new Employer { AccountId = 1, AccountName = "account 1", AccountLegalEntityId = 11, AccountLegalEntityName = "Entity 1" }, new Employer { AccountId = 2, AccountName = "account 2", AccountLegalEntityId = 22, AccountLegalEntityName = "Entity 2" } }; _query = new GetTrustedEmployersQuery { UkPrn = ExpectedUkPrn }; _providerPermissionsService = new Mock <IProviderPermissionsService>(); _validator = new Mock <IValidator <GetTrustedEmployersQuery> >(); _handler = new GetTrustedEmployersQueryHandler(_providerPermissionsService.Object, _validator.Object); _providerPermissionsService.Setup(s => s.GetTrustedEmployers(ExpectedUkPrn)).ReturnsAsync(_expectedEmployers); _validator.Setup(v => v.ValidateAsync(It.IsAny <GetTrustedEmployersQuery>())) .ReturnsAsync(new ValidationResult()); }
public async Task And_All_Fields_Valid_Then_Valid( GetTrustedEmployersQuery query, GetTrustedEmployerQueryValidator validator) { var result = await validator.ValidateAsync(query); result.IsValid().Should().BeTrue(); result.ValidationDictionary.Count.Should().Be(0); }
public async Task And_No_Id_Then_Invalid( GetTrustedEmployerQueryValidator validator) { var query = new GetTrustedEmployersQuery(); var result = await validator.ValidateAsync(query); result.IsValid().Should().BeFalse(); result.ValidationDictionary.Count.Should().Be(1); result.ValidationDictionary .Should().ContainKey(nameof(GetTrustedEmployersQuery.UkPrn)) .WhichValue.Should().Be($"{nameof(GetTrustedEmployersQuery.UkPrn)} has not been supplied"); }
public void Arrange() { _expectedAccountLegalEntities = new List <AccountLegalEntity> { new AccountLegalEntity { AccountId = 1, AgreementSigned = false, AccountName = "account 1", AccountLegalEntityId = 11, AccountLegalEntityName = "Entity 1" }, new AccountLegalEntity { AccountId = 2, AgreementSigned = true, AccountName = "account 2", AccountLegalEntityId = 22, AccountLegalEntityName = "Entity 2" } }; _query = new GetTrustedEmployersQuery { UkPrn = ExpectedUkPrn }; _encodingService = new Mock <IEncodingService>(); _encodingService.Setup(x => x.Encode(It.IsAny <long>(), EncodingType.PublicAccountLegalEntityId)) .Returns("ABC123"); _encodingService.Setup(x => x.Encode(It.IsAny <long>(), EncodingType.PublicAccountId)) .Returns("DEF456"); _providerService = new Mock <IProviderService>(); _validator = new Mock <IValidator <GetTrustedEmployersQuery> >(); _handler = new GetTrustedEmployersQueryHandler(_providerService.Object, _encodingService.Object, _validator.Object); _providerService.Setup(s => s.GetTrustedEmployers(ExpectedUkPrn)).ReturnsAsync(_expectedAccountLegalEntities); _validator.Setup(v => v.ValidateAsync(It.IsAny <GetTrustedEmployersQuery>())) .ReturnsAsync(new ValidationResult()); }