public void TestAtBudgetkontoplanHentes() { var query = new BudgetkontoplanGetQuery { Regnskabsnummer = 1, StatusDato = new DateTime(2011, 3, 1) }; var result = _service.BudgetkontoplanGet(query); Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.GreaterThan(0)); }
/// <summary> /// Henter og returnerer en budgetkontoplan. /// </summary> /// <param name="query">Forespørgelse til at hente en kontokontoplan.</param> /// <returns>Budgetkontoplan.</returns> public IEnumerable <BudgetkontoplanView> Query(BudgetkontoplanGetQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var budgetkonti = BudgetkontoGetAllByRegnskab(query.Regnskabsnummer).ToList(); budgetkonti.ForEach(m => m.Calculate(query.StatusDato)); return(MapMany <Budgetkonto, BudgetkontoplanView>(budgetkonti)); }
public void TestAtBudgetkontoplanHentes() { var client = _channelFactory.CreateChannel <IFinansstyringService>(ClientEndpointName); try { var query = new BudgetkontoplanGetQuery { Regnskabsnummer = 1, StatusDato = new DateTime(2011, 3, 1) }; var result = client.BudgetkontoplanGet(query); Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.GreaterThan(0)); } finally { ChannelTools.CloseChannel(client); } }
public IEnumerable <BudgetkontoplanView> BudgetkontoplanGet(BudgetkontoplanGetQuery query) { try { return(_queryBus.Query <BudgetkontoplanGetQuery, IEnumerable <BudgetkontoplanView> >(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 TestAtQueryHenterBudgetkontoplan() { var fixture = new Fixture(); var regnskab = fixture.Create <Regnskab>(); foreach (var budgetknt in fixture.CreateMany <Budgetkonto>(3)) { regnskab.TilføjKonto(budgetknt); var tempDate = DateTime.Now.AddMonths(12); for (var i = 0; i < 24; i++) { budgetknt.TilføjBudgetoplysninger(new Budgetoplysninger(tempDate.Year, tempDate.Month, fixture.Create <decimal>(), fixture.Create <decimal>())); tempDate = tempDate.AddMonths(-1); } foreach (var bogføringslinje in fixture.CreateMany <Bogføringslinje>(250)) { budgetknt.TilføjBogføringslinje(bogføringslinje); } } var finansstyringRepository = MockRepository.GenerateMock <IFinansstyringRepository>(); finansstyringRepository.Expect( m => m.RegnskabGet(Arg <int> .Is.Anything, Arg <Func <int, Brevhoved> > .Is.NotNull, Arg <Func <int, AdresseBase> > .Is.NotNull)) .Return(regnskab); var adresseRepository = MockRepository.GenerateMock <IAdresseRepository>(); adresseRepository.Expect(m => m.AdresseGetAll()) .Return(fixture.CreateMany <Person>(25)); var fællesRepository = MockRepository.GenerateMock <IFællesRepository>(); fællesRepository.Expect(m => m.BrevhovedGetAll()) .Return(fixture.CreateMany <Brevhoved>(3)); var objectMapper = MockRepository.GenerateMock <IObjectMapper>(); objectMapper.Expect( m => m.Map <IEnumerable <Budgetkonto>, IEnumerable <BudgetkontoplanView> >( Arg <IEnumerable <Budgetkonto> > .Is.NotNull)).Return(fixture.CreateMany <BudgetkontoplanView>(3)); fixture.Inject(finansstyringRepository); fixture.Inject(adresseRepository); fixture.Inject(fællesRepository); fixture.Inject(objectMapper); var queryHandler = fixture.Create <BudgetkontoplanGetQueryHandler>(); Assert.That(queryHandler, Is.Not.Null); var query = new BudgetkontoplanGetQuery { Regnskabsnummer = regnskab.Nummer, StatusDato = fixture.Create <DateTime>() }; Assert.That(query, Is.Not.Null); var budgetkontoplan = queryHandler.Query(query); Assert.That(budgetkontoplan, Is.Not.Null); Assert.That(budgetkontoplan.Count(), Is.EqualTo(3)); finansstyringRepository.AssertWasCalled( m => m.RegnskabGet(Arg <int> .Is.Equal(query.Regnskabsnummer), Arg <Func <int, Brevhoved> > .Is.NotNull, Arg <Func <int, AdresseBase> > .Is.NotNull)); adresseRepository.AssertWasCalled(m => m.AdresseGetAll()); fællesRepository.AssertWasCalled(m => m.BrevhovedGetAll()); objectMapper.AssertWasCalled( m => m.Map <IEnumerable <Budgetkonto>, IEnumerable <BudgetkontoplanView> >( Arg <IEnumerable <Budgetkonto> > .Is.NotNull)); }