Пример #1
0
        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 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());
        }