Exemplo n.º 1
0
        private void SetupContext()
        {
            _ovoNumber = new OvoNumber("OVO000015");

            _dataVlaanderenProviderMock = new Mock <IDataVlaanderenProvider>();
            _wegwijsProviderMock        = new Mock <IWegwijsProvider>();

            _dataVlaanderenProviderMock
            .Setup(provider => provider.GetOrganisationAsync(_ovoNumber))
            .ThrowsAsync(new Exception());

            _dataVlaanderenProviderMock
            .Setup(provider => provider.GetOrganisationFailedMessage())
            .Returns("error message");

            _wegwijsProviderMock
            .Setup(provider => provider.GetOrganisationAsync(_ovoNumber))
            .ReturnsAsync(() => new Optional <Organisation>(
                              new Organisation
            {
                Name       = new OrganisationName("Departement van verloren straten"),
                OvoNumber  = _ovoNumber,
                Provenance = OrganisationProvenance.FromWegwijsSearch("uri//12")
            }));

            _sut = new OrganisationProvider(
                Mock.Of <ILogger <OrganisationProvider> >(),
                _dataVlaanderenProviderMock.Object,
                _wegwijsProviderMock.Object);
        }
        private void SetupContext()
        {
            _ovoNumber = new OvoNumber("OVO000015");
            _datavlaanderenOrganisationName = new OrganisationName("Departement van verloren gebouwen");
            _provenanceUri = "uri//11";

            var dataVlaanderenProviderMock = new Mock <IDataVlaanderenProvider>();

            _wegwijsProviderMock = new Mock <IWegwijsProvider>();

            dataVlaanderenProviderMock
            .Setup(provider => provider.GetOrganisationAsync(_ovoNumber))
            .ReturnsAsync(() => new Optional <Organisation>(
                              new Organisation
            {
                Name       = _datavlaanderenOrganisationName,
                OvoNumber  = _ovoNumber,
                Provenance = OrganisationProvenance.FromDataVlaanderen(_provenanceUri)
            }));

            _sut = new OrganisationProvider(
                Mock.Of <ILogger <OrganisationProvider> >(),
                dataVlaanderenProviderMock.Object,
                _wegwijsProviderMock.Object);
        }
Exemplo n.º 3
0
 public void Customize(IFixture fixture)
 {
     fixture.Customize <Organisation>(c => c.FromFactory(() => new Organisation
     {
         Name       = new OrganisationName(fixture.Create <string>()),
         OvoNumber  = fixture.Create <OvoNumber>(),
         Provenance = OrganisationProvenance.From(OrganisationSource.DataVlaanderen, fixture.Create <Uri>().ToString())
     }));
 }
        public async Task <Optional <Organisation> > GetOrganisationAsync(OvoNumber ovoNumber)
        {
            var httpResponseMessage = await _dataVlaanderenClient.GetAsync(ovoNumber);

            var responseContent = await httpResponseMessage.Content.ReadAsStringAsync();

            var dataVlaanderenOrganisation = DataVlaanderenOrganisation.FromJson(
                DataVlaanderenBaseUri + ovoNumber,
                responseContent);

            if (dataVlaanderenOrganisation.HasValue)
            {
                return(new Optional <Organisation>(
                           new Organisation
                {
                    Name = new OrganisationName(dataVlaanderenOrganisation.Value.PrefLabel),
                    OvoNumber = ovoNumber,
                    Provenance = OrganisationProvenance.FromDataVlaanderen(httpResponseMessage.RequestMessage.RequestUri.ToString())
                }));
            }

            return(Optional <Organisation> .Empty);
        }
Exemplo n.º 5
0
        public async Task <Optional <Organisation> > GetOrganisationAsync(OvoNumber ovoNumber)
        {
            var responseMessage = await _wegwijsVlaanderenClient.GetAsync("organisations?q=ovoNumber:" + ovoNumber);

            var responseText = await responseMessage.Content.ReadAsStringAsync();

            var searchResult = JsonConvert.DeserializeObject <WegwijsOrganisation[]>(responseText);

            if (searchResult.Length != 1)
            {
                return(Optional <Organisation> .Empty);
            }

            var organisation = searchResult.Single();

            return(new Optional <Organisation>(
                       new Organisation
            {
                Name = new OrganisationName(organisation.Name),
                OvoNumber = ovoNumber,
                Provenance = OrganisationProvenance.FromWegwijsSearch(responseMessage.RequestMessage.RequestUri.ToString())
            }));
        }