Beispiel #1
0
        public void TestAtKreditorlisteKanHentes()
        {
            var query = new KreditorlisteGetQuery
            {
                Regnskabsnummer = 1,
                StatusDato      = new DateTime(2010, 8, 10)
            };
            var result = _service.KreditorlisteGet(query);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.GreaterThan(0));
        }
        /// <summary>
        /// Henter og returnerer en kreditorliste.
        /// </summary>
        /// <param name="query">Forespørgelse til at hente en kreditorliste.</param>
        /// <returns>Kreditorliste</returns>
        public IEnumerable <KreditorlisteView> Query(KreditorlisteGetQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var overNul    = _konfigurationRepository.KreditorSaldoOverNul;
            var kreditorer = AdressekontoGetAllWithValueByRegnskabAndStatusDato(query.Regnskabsnummer, query.StatusDato,
                                                                                overNul);

            return(MapMany <AdresseBase, KreditorlisteView>(kreditorer));
        }
Beispiel #3
0
        public void TestAtKreditorlisteKanHentes()
        {
            var client = _channelFactory.CreateChannel <IFinansstyringService>(ClientEndpointName);

            try
            {
                var query = new KreditorlisteGetQuery
                {
                    Regnskabsnummer = 1,
                    StatusDato      = new DateTime(2010, 8, 10)
                };
                var result = client.KreditorlisteGet(query);
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.GreaterThan(0));
            }
            finally
            {
                ChannelTools.CloseChannel(client);
            }
        }
 public IEnumerable <KreditorlisteView> KreditorlisteGet(KreditorlisteGetQuery query)
 {
     try
     {
         return(_queryBus.Query <KreditorlisteGetQuery, IEnumerable <KreditorlisteView> >(query));
     }
     catch (IntranetRepositoryException ex)
     {
         throw CreateIntranetRepositoryFault(ex);
     }
     catch (IntranetBusinessException ex)
     {
         throw CreateIntranetBusinessFault(ex);
     }
     catch (IntranetSystemException ex)
     {
         throw CreateIntranetSystemFault(ex);
     }
     catch (Exception ex)
     {
         throw CreateIntranetSystemFault(ex);
     }
 }
        public void TestAtQueryHenterKreditorer()
        {
            var fixture = new Fixture();

            fixture.Inject(new DateTime(2011, 6, 30));
            var debitorer = fixture.CreateMany <Person>(15).ToList();

            debitorer.ForEach(
                m =>
                m.TilføjBogføringslinje(new Bogføringslinje(fixture.Create <int>(),
                                                            fixture.Create <DateTime>(),
                                                            fixture.Create <string>(),
                                                            fixture.Create <string>(),
                                                            fixture.Create <decimal>(), 0M)));
            var kreditorer = fixture.CreateMany <Person>(15).ToList();

            kreditorer.ForEach(
                m =>
                m.TilføjBogføringslinje(new Bogføringslinje(fixture.Create <int>(),
                                                            fixture.Create <DateTime>(),
                                                            fixture.Create <string>(),
                                                            fixture.Create <string>(), 0M,
                                                            fixture.Create <decimal>())));
            var personer = new List <Person>();

            personer.AddRange(debitorer);
            personer.AddRange(kreditorer);

            var finansstyringRepository = MockRepository.GenerateMock <IFinansstyringRepository>();
            var adresseRepository       = MockRepository.GenerateMock <IAdresseRepository>();

            adresseRepository.Expect(m => m.AdresseGetAll())
            .Return(personer);
            var fællesRepository = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepository.Expect(m => m.BrevhovedGetAll())
            .Return(fixture.CreateMany <Brevhoved>(3));
            var konfigurationRepository = MockRepository.GenerateMock <IKonfigurationRepository>();

            konfigurationRepository.Expect(m => m.KreditorSaldoOverNul)
            .Return(false);
            var objectMapper = MockRepository.GenerateMock <IObjectMapper>();

            objectMapper.Expect(
                m =>
                m.Map <IEnumerable <AdresseBase>, IEnumerable <KreditorlisteView> >(Arg <IEnumerable <AdresseBase> > .Is.NotNull))
            .Return(fixture.CreateMany <KreditorlisteView>(kreditorer.Count));

            fixture.Inject(finansstyringRepository);
            fixture.Inject(adresseRepository);
            fixture.Inject(fællesRepository);
            fixture.Inject(konfigurationRepository);
            fixture.Inject(objectMapper);
            var queryHandler = fixture.Create <KreditorlisteGetQueryHandler>();

            Assert.That(queryHandler, Is.Not.Null);

            var query = new KreditorlisteGetQuery
            {
                Regnskabsnummer = fixture.Create <int>(),
                StatusDato      = fixture.Create <DateTime>()
            };
            var result = queryHandler.Query(query);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.EqualTo(kreditorer.Count));

            adresseRepository.AssertWasCalled(m => m.AdresseGetAll());
            fællesRepository.AssertWasCalled(m => m.BrevhovedGetAll());
            konfigurationRepository.AssertWasCalled(m => m.KreditorSaldoOverNul);
            objectMapper.AssertWasCalled(
                m =>
                m.Map <IEnumerable <AdresseBase>, IEnumerable <KreditorlisteView> >(Arg <IEnumerable <AdresseBase> > .Is.NotNull));
        }