public void TestAtBogføringslinjeCreateNewAsyncArgumentNullExceptionVedIllegalKontonummer(string illegalValue) { var fixture = new Fixture(); fixture.Customize <DateTime>(e => e.FromFactory(() => DateTime.Now)); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); ArgumentNullException exception = null; var aggregateException = Assert.Throws <AggregateException>(() => finansstyringRepository.BogføringslinjeCreateNewAsync(fixture.Create <int>(), fixture.Create <DateTime>(), illegalValue).Wait()); aggregateException.Handle(e => { exception = e as ArgumentNullException; return(true); }); Assert.That(exception, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Empty); Assert.That(exception.ParamName, Is.EqualTo("kontonummer")); Assert.That(exception.InnerException, Is.Null); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtRegnskabslisteGetKasterIntranetRepositoryExceptionVedException() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.RegnskabGetAll(Arg <RegnskabGetAllQuery> .Is.Anything)) .Throw(fixture.Create <Exception>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed).Repeat.Any(); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var getBrevhovedCallback = new Func <int, Brevhoved>(nummer => fixture.Create <Brevhoved>()); Assert.That(getBrevhovedCallback, Is.Not.Null); Assert.That(getBrevhovedCallback(1), Is.Not.Null); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); Assert.Throws <IntranetRepositoryException>(() => repository.RegnskabslisteGet(getBrevhovedCallback)); }
public void TestAtBogføringslinjeCreateNewAsyncArgumentExceptionVedIllegalDato(string illegalValue) { var fixture = new Fixture(); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var dato = Convert.ToDateTime(illegalValue, new CultureInfo("en-US")); ArgumentException exception = null; var aggregateException = Assert.Throws <AggregateException>(() => finansstyringRepository.BogføringslinjeCreateNewAsync(fixture.Create <int>(), dato, fixture.Create <string>()).Wait()); aggregateException.Handle(e => { exception = e as ArgumentException; return(true); }); Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.Not.Null); Assert.That(exception.Message, Is.Not.Empty); Assert.That(exception.Message, Does.StartWith(Resource.GetExceptionMessage(ExceptionMessage.IllegalArgumentValue, "dato", dato))); Assert.That(exception.ParamName, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Empty); Assert.That(exception.ParamName, Is.EqualTo("dato")); Assert.That(exception.InnerException, Is.Null); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtBogføringslinjeAddKasterIntranetRepositoryExceptionVedException() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.Anything)) .Throw(fixture.Create <Exception>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); Assert.Throws <IntranetRepositoryException>( () => repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, fixture.Create <string>(), null, fixture.Create <decimal>(), fixture.Create <decimal>(), null)); }
public void TestAtBogføringslinjeCreateNewAsyncArgumentExceptionVedIllegalRegnskabsnummer(int illegalValue) { var fixture = new Fixture(); fixture.Customize <DateTime>(e => e.FromFactory(() => DateTime.Now)); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); ArgumentException exception = null; var aggregateException = Assert.Throws <AggregateException>(() => finansstyringRepository.BogføringslinjeCreateNewAsync(illegalValue, fixture.Create <DateTime>(), fixture.Create <string>()).Wait()); aggregateException.Handle(e => { exception = e as ArgumentException; return(true); }); Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.Not.Null); Assert.That(exception.Message, Is.Not.Empty); Assert.That(exception.Message, Does.StartWith(Resource.GetExceptionMessage(ExceptionMessage.IllegalArgumentValue, "regnskabsnummer", illegalValue))); Assert.That(exception.ParamName, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Empty); Assert.That(exception.ParamName, Is.EqualTo("regnskabsnummer")); Assert.That(exception.InnerException, Is.Null); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtRegnskabGetKasterArgumentNullExceptionHvisGetAdresseCallbackErNull() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.RegnskabGetByNummer(Arg <RegnskabGetByNummerQuery> .Is.Anything)) .Throw(fixture.Create <IntranetRepositoryException>()); service.Expect(m => m.KontogruppeGetAll(Arg <KontogruppeGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <KontogruppeView>(3)); service.Expect(m => m.BudgetkontogruppeGetAll(Arg <BudgetkontogruppeGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <BudgetkontogruppeView>(3)); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var getBrevhovedCallback = new Func <int, Brevhoved>(nummer => fixture.Create <Brevhoved>()); Assert.That(getBrevhovedCallback, Is.Not.Null); Assert.That(getBrevhovedCallback(1), Is.Not.Null); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); Assert.Throws <ArgumentNullException>(() => repository.RegnskabGet(fixture.Create <int>(), getBrevhovedCallback, null)); }
public void TestAtBogførAsyncBogførerValues() { var fixture = new Fixture(); fixture.Customize <DateTime>(e => e.FromFactory(() => DateTime.Now)); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); finansstyringKonfigurationRepositoryMock.Expect(m => m.FinansstyringServiceUri) .Return(new Uri(FinansstyringServiceTestUri)) .Repeat.Any(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var task1 = finansstyringRepository.BogførAsync(1, fixture.Create <DateTime>(), null, "DANKORT", "Test", "8990", 5000M, 0M, 0); task1.Wait(); Assert.That(task1.Result, Is.Not.Null); Assert.That(task1.Result.Bogføringslinje, Is.Not.Null); Assert.That(task1.Result.Bogføringsadvarsler, Is.Not.Null); var task2 = finansstyringRepository.BogførAsync(1, fixture.Create <DateTime>(), null, "DANKORT", "Test", "8990", 0M, 5000M, 0); task2.Wait(); Assert.That(task2.Result, Is.Not.Null); Assert.That(task2.Result.Bogføringslinje, Is.Not.Null); Assert.That(task2.Result.Bogføringsadvarsler, Is.Not.Null); finansstyringKonfigurationRepositoryMock.AssertWasCalled(m => m.FinansstyringServiceUri); }
public void TestAtAdressekontoGetAsyncHenterAdressekonto() { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); finansstyringKonfigurationRepositoryMock.Expect(m => m.FinansstyringServiceUri) .Return(new Uri(FinansstyringServiceTestUri)) .Repeat.Any(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var statusDato = DateTime.Now; var task = finansstyringRepository.AdressekontoGetAsync(1, 1, statusDato); task.Wait(); var adressekonto = task.Result; Assert.That(adressekonto, Is.Not.Null); Assert.That(adressekonto.Regnskabsnummer, Is.EqualTo(1)); Assert.That(adressekonto.Nummer, Is.EqualTo(1)); Assert.That(adressekonto.StatusDato, Is.EqualTo(statusDato)); finansstyringKonfigurationRepositoryMock.AssertWasCalled(m => m.FinansstyringServiceUri); }
public void TestAtBogførAsyncKasterArgumentExceptionVedIllegalKredit(decimal illegalValue) { var fixture = new Fixture(); fixture.Customize <DateTime>(e => e.FromFactory(() => DateTime.Now)); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var exception = Assert.Throws <ArgumentException>(() => finansstyringRepository.BogførAsync(fixture.Create <int>(), fixture.Create <DateTime>(), fixture.Create <string>(), fixture.Create <string>(), fixture.Create <string>(), fixture.Create <string>(), fixture.Create <decimal>(), illegalValue, fixture.Create <int>()).Wait()); Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.Not.Null); Assert.That(exception.Message, Is.Not.Empty); Assert.That(exception.Message, Does.StartWith(Resource.GetExceptionMessage(ExceptionMessage.IllegalArgumentValue, "kredit", illegalValue))); Assert.That(exception.ParamName, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Empty); Assert.That(exception.ParamName, Is.EqualTo("kredit")); Assert.That(exception.InnerException, Is.Null); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtBudgetkontogruppeGetAllHenterAlleBudgetkontogrupper() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BudgetkontogruppeGetAll(Arg <BudgetkontogruppeGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <BudgetkontogruppeView>(3)); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); domainObjectBuilder.Expect( m => m.BuildMany <BudgetkontogruppeView, Budgetkontogruppe>(Arg <IEnumerable <BudgetkontogruppeView> > .Is.NotNull)) .Return(fixture.CreateMany <Budgetkontogruppe>(3)); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var budgetkontogrupper = repository.BudgetkontogruppeGetAll(); Assert.That(budgetkontogrupper, Is.Not.Null); Assert.That(budgetkontogrupper.Count(), Is.EqualTo(3)); domainObjectBuilder.AssertWasCalled( m => m.BuildMany <BudgetkontogruppeView, Budgetkontogruppe>(Arg <IEnumerable <BudgetkontogruppeView> > .Is.NotNull)); }
public void TestAtRegnskabGetHenterRegnskab() { var fixture = new Fixture(); fixture.Inject <IEnumerable <KontoView> >(new List <KontoView>()); fixture.Inject <IEnumerable <BudgetkontoView> >(new List <BudgetkontoView>()); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.RegnskabGetByNummer(Arg <RegnskabGetByNummerQuery> .Is.Anything)) .Return(fixture.Create <RegnskabView>()); service.Expect(m => m.KontogruppeGetAll(Arg <KontogruppeGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <KontogruppeView>(3)); service.Expect(m => m.BudgetkontogruppeGetAll(Arg <BudgetkontogruppeGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <BudgetkontogruppeView>(3)); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); domainObjectBuilder.Expect( m => m.BuildMany <KontogruppeView, Kontogruppe>(Arg <IEnumerable <KontogruppeView> > .Is.NotNull)) .Return(fixture.CreateMany <Kontogruppe>(3)); domainObjectBuilder.Expect( m => m.BuildMany <BudgetkontogruppeView, Budgetkontogruppe>(Arg <IEnumerable <BudgetkontogruppeView> > .Is.NotNull)) .Return(fixture.CreateMany <Budgetkontogruppe>(3)); domainObjectBuilder.Expect(m => m.Build <RegnskabView, Regnskab>(Arg <RegnskabView> .Is.NotNull)) .Return(fixture.Create <Regnskab>()); var getBrevhovedCallback = new Func <int, Brevhoved>(nummer => fixture.Create <Brevhoved>()); Assert.That(getBrevhovedCallback, Is.Not.Null); Assert.That(getBrevhovedCallback(1), Is.Not.Null); var getAdresseCallback = new Func <int, AdresseBase>(nummer => fixture.Create <Person>()); Assert.That(getAdresseCallback, Is.Not.Null); Assert.That(getAdresseCallback(1), Is.Not.Null); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var regnskab = repository.RegnskabGet(fixture.Create <int>(), getBrevhovedCallback, getAdresseCallback); Assert.That(regnskab, Is.Not.Null); domainObjectBuilder.AssertWasCalled( m => m.BuildMany <KontogruppeView, Kontogruppe>(Arg <IEnumerable <KontogruppeView> > .Is.NotNull)); domainObjectBuilder.AssertWasCalled( m => m.BuildMany <BudgetkontogruppeView, Budgetkontogruppe>(Arg <IEnumerable <BudgetkontogruppeView> > .Is.NotNull)); domainObjectBuilder.AssertWasCalled(m => m.Build <RegnskabView, Regnskab>(Arg <RegnskabView> .Is.NotNull)); }
public void TestAtConstructorInitiererFinansstyringRepository() { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); Assert.That(finansstyringRepository.Konfiguration, Is.Not.Null); Assert.That(finansstyringRepository.Konfiguration, Is.EqualTo(finansstyringKonfigurationRepositoryMock)); }
public void TestAtBogføringslinjeAddKasterEnArgumentNullExceptionHvisTekstErNull() { var fixture = new Fixture(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); Assert.Throws <ArgumentNullException>( () => repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, null, null, fixture.Create <decimal>(), fixture.Create <decimal>(), null)); }
public void TestAtBudgetkontoGetAsyncKasterArgumentNullExceptionVedIllegalKontonummer(string illegalKontonummer) { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var exception = Assert.Throws <ArgumentNullException>(() => finansstyringRepository.BudgetkontoGetAsync(1, illegalKontonummer, DateTime.Now).Wait()); Assert.That(exception, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Null); Assert.That(exception.ParamName, Is.Not.Empty); Assert.That(exception.ParamName, Is.EqualTo("budgetkontonummer")); Assert.That(exception.InnerException, Is.Null); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtRegnskabslisteGetKasterArgumentNullExceptionHvisGetBrevhovedCallbackErNull() { var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed).Repeat.Any(); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); Assert.Throws <ArgumentNullException>(() => repository.RegnskabslisteGet(null)); }
public void TestAtAdressekontolisteGetAsyncHenterAdressekontoliste() { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); finansstyringKonfigurationRepositoryMock.Expect(m => m.FinansstyringServiceUri) .Return(new Uri(FinansstyringServiceTestUri)) .Repeat.Any(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var task = finansstyringRepository.AdressekontolisteGetAsync(1, DateTime.Now); task.Wait(); Assert.That(task.Result, Is.Not.Null); Assert.That(task.Result.Count(), Is.GreaterThanOrEqualTo(0)); finansstyringKonfigurationRepositoryMock.AssertWasCalled(m => m.FinansstyringServiceUri); }
public void TestAtBudgetkontogruppelisteGetAsyncHenterBudgetkontogrupper() { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); finansstyringKonfigurationRepositoryMock.Expect(m => m.FinansstyringServiceUri) .Return(new Uri(FinansstyringServiceTestUri)) .Repeat.Any(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var task = finansstyringRepository.BudgetkontogruppelisteGetAsync(); task.Wait(); Assert.That(task.Result, Is.Not.Null); Assert.That(task.Result, Is.Not.Empty); finansstyringKonfigurationRepositoryMock.AssertWasCalled(m => m.FinansstyringServiceUri); }
public void TestAtBogføringslinjerGetAsyncHenterBogføringslinjer() { var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); finansstyringKonfigurationRepositoryMock.Expect(m => m.FinansstyringServiceUri) .Return(new Uri(FinansstyringServiceTestUri)) .Repeat.Any(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var task = finansstyringRepository.BogføringslinjerGetAsync(1, DateTime.Now, 50); task.Wait(); Assert.That(task.Result, Is.Not.Null); Assert.That(task.Result, Is.Not.Empty); Assert.That(task.Result.Count(), Is.EqualTo(50)); finansstyringKonfigurationRepositoryMock.AssertWasCalled(m => m.FinansstyringServiceUri); }
public void TestAtBudgetkontogruppeGetAllKasterIntranetRepositoryExceptionVedException() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BudgetkontogruppeGetAll(Arg <BudgetkontogruppeGetAllQuery> .Is.Anything)) .Throw(fixture.Create <Exception>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); Assert.Throws <IntranetRepositoryException>(() => repository.BudgetkontogruppeGetAll()); }
public void TestAtRegnskabslisteGetHenterAlleRegnskaber() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.RegnskabGetAll(Arg <RegnskabGetAllQuery> .Is.Anything)) .Return(fixture.CreateMany <RegnskabListeView>(3)); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed).Repeat.Any(); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); domainObjectBuilder.Expect( m => m.BuildMany <RegnskabListeView, Regnskab>(Arg <IEnumerable <RegnskabListeView> > .Is.NotNull)) .Return(fixture.CreateMany <Regnskab>(3)); var getBrevhovedCallback = new Func <int, Brevhoved>(nummer => fixture.Create <Brevhoved>()); Assert.That(getBrevhovedCallback, Is.Not.Null); Assert.That(getBrevhovedCallback(1), Is.Not.Null); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var regnskaber = repository.RegnskabslisteGet(getBrevhovedCallback); Assert.That(regnskaber, Is.Not.Null); Assert.That(regnskaber.Count(), Is.EqualTo(3)); domainObjectBuilder.AssertWasCalled( m => m.BuildMany <RegnskabListeView, Regnskab>(Arg <IEnumerable <RegnskabListeView> > .Is.NotNull)); }
public void TestAtBogføringslinjeCreateNewAsyncDannerBogføringslinjeModel() { var fixture = new Fixture(); fixture.Customize <DateTime>(e => e.FromFactory(() => DateTime.Now)); var finansstyringKonfigurationRepositoryMock = MockRepository.GenerateMock <IFinansstyringKonfigurationRepository>(); var finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepositoryMock); Assert.That(finansstyringRepository, Is.Not.Null); var regnskabsnummer = fixture.Create <int>(); var dato = fixture.Create <DateTime>(); var kontonummer = fixture.Create <string>(); var task = finansstyringRepository.BogføringslinjeCreateNewAsync(regnskabsnummer, dato, kontonummer); task.Wait(); var bogføringslinjeModel = task.Result; Assert.That(bogføringslinjeModel, Is.Not.Null); Assert.That(bogføringslinjeModel.Regnskabsnummer, Is.EqualTo(regnskabsnummer)); Assert.That(bogføringslinjeModel.Løbenummer, Is.EqualTo(int.MinValue)); Assert.That(bogføringslinjeModel.Dato, Is.EqualTo(dato)); Assert.That(bogføringslinjeModel.Bilag, Is.Null); Assert.That(bogføringslinjeModel.Kontonummer, Is.Not.Null); Assert.That(bogføringslinjeModel.Kontonummer, Is.Not.Empty); Assert.That(bogføringslinjeModel.Kontonummer, Is.EqualTo(kontonummer)); Assert.That(bogføringslinjeModel.Tekst, Is.Not.Null); Assert.That(bogføringslinjeModel.Tekst, Is.Empty); Assert.That(bogføringslinjeModel.Budgetkontonummer, Is.Null); Assert.That(bogføringslinjeModel.Debit, Is.EqualTo(0M)); Assert.That(bogføringslinjeModel.Kredit, Is.EqualTo(0M)); finansstyringKonfigurationRepositoryMock.AssertWasNotCalled(m => m.FinansstyringServiceUri); }
public void TestAtBogføringslinjeAddKalderServicemetode() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.NotNull)) .Return(fixture.Create <BogføringslinjeView>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); var budgetkonto = fixture.Create <Budgetkonto>(); var adressekonto = fixture.Create <Person>(); var result = repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, fixture.Create <string>(), budgetkonto, fixture.Create <decimal>(), fixture.Create <decimal>(), adressekonto); Assert.That(result, Is.Not.Null); Assert.That(konto.Bogføringslinjer.Count(), Is.EqualTo(1)); Assert.That(budgetkonto.Bogføringslinjer.Count(), Is.EqualTo(1)); Assert.That(adressekonto.Bogføringslinjer.Count(), Is.EqualTo(1)); service.AssertWasCalled(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.NotNull)); }
/// <summary> /// Starter baggrundstask, der kan loaded nyheder til finansstyring. /// </summary> /// <param name="taskInstance">Instans af baggrundstasken.</param> public async void Run(IBackgroundTaskInstance taskInstance) { lock (SyncRoot) { if (_isLoading) { return; } _isLoading = true; } BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); try { WindowsRuntimeResourceManager.PatchResourceManagers(); ConfigurationProvider configurationProvider = new ConfigurationProvider(); IDictionary <string, object> finansstyringConfiguration = configurationProvider.Settings .Where(m => FinansstyringKonfigurationRepository.Keys.Contains(m.Key)) .ToDictionary(m => m.Key, m => m.Value); IFinansstyringKonfigurationRepository finansstyringKonfigurationRepository = new FinansstyringKonfigurationRepository(); finansstyringKonfigurationRepository.KonfigurationerAdd(finansstyringConfiguration); IEnumerable <INyhedModel> finansstyringsnyheder; try { IFinansstyringRepository finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepository); finansstyringsnyheder = await FinansstyringsnyhederGetAsync(finansstyringRepository); } catch (IntranetGuiOfflineRepositoryException) { ILocaleDataStorage localeDataStorage = new LocaleDataStorage(finansstyringKonfigurationRepository.LokalDataFil, finansstyringKonfigurationRepository.SynkroniseringDataFil, FinansstyringRepositoryLocale.XmlSchema); localeDataStorage.OnHasLocaleData += LocaleDataStorageHelper.HasLocaleDataEventHandler; localeDataStorage.OnCreateReaderStream += LocaleDataStorageHelper.CreateReaderStreamEventHandler; localeDataStorage.OnCreateWriterStream += LocaleDataStorageHelper.CreateWriterStreamEventHandler; IFinansstyringRepository finansstyringRepository = new FinansstyringRepositoryLocale(finansstyringKonfigurationRepository, localeDataStorage); Task <IEnumerable <INyhedModel> > finansstyringsnyhederGetTask = FinansstyringsnyhederGetAsync(finansstyringRepository); finansstyringsnyhederGetTask.Wait(); finansstyringsnyheder = finansstyringsnyhederGetTask.Result; } UpdateTile(finansstyringsnyheder); } catch (AggregateException aggregateException) { aggregateException.Handle(ex => { Logger.LogError(ex); return(true); }); } catch (Exception ex) { Logger.LogError(ex); } finally { lock (SyncRoot) { _isLoading = false; } deferral.Complete(); } }
/// <summary> /// Sarter baggrundstask, der kan synkronisere finansstyringsdata til og fra det lokale datalager. /// </summary> /// <param name="taskInstance">Instans af baggrundstasken.</param> public async void Run(IBackgroundTaskInstance taskInstance) { lock (SyncRoot) { if (_isSynchronizing) { return; } _isSynchronizing = true; _cancelRequested = false; } taskInstance.Canceled += CanceledEventHandler; BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); try { WindowsRuntimeResourceManager.PatchResourceManagers(); ConfigurationProvider configurationProvider = new ConfigurationProvider(); IDictionary <string, object> finansstyringConfiguration = configurationProvider.Settings .Where(m => FinansstyringKonfigurationRepository.Keys.Contains(m.Key)) .ToDictionary(m => m.Key, m => m.Value); IFinansstyringKonfigurationRepository finansstyringKonfigurationRepository = new FinansstyringKonfigurationRepository(); finansstyringKonfigurationRepository.KonfigurationerAdd(finansstyringConfiguration); IFinansstyringRepository finansstyringRepository = new FinansstyringRepository(finansstyringKonfigurationRepository); ILocaleDataStorage localeDataStorage = new LocaleDataStorage(finansstyringKonfigurationRepository.LokalDataFil, finansstyringKonfigurationRepository.SynkroniseringDataFil, FinansstyringRepositoryLocale.XmlSchema); localeDataStorage.OnHasLocaleData += LocaleDataStorageHelper.HasLocaleDataEventHandler; localeDataStorage.OnCreateReaderStream += LocaleDataStorageHelper.CreateReaderStreamEventHandler; localeDataStorage.OnCreateWriterStream += LocaleDataStorageHelper.CreateWriterStreamEventHandler; localeDataStorage.PrepareLocaleData += PrepareLocaleDataEventHandler; await SyncData(finansstyringRepository, finansstyringKonfigurationRepository, localeDataStorage); } catch (AggregateException aggregateException) { aggregateException.Handle(ex => { if (ex is IntranetGuiOfflineRepositoryException) { return(true); } Logger.LogError(ex); return(true); }); } catch (Exception ex) { Logger.LogError(ex); } finally { lock (SyncRoot) { _isSynchronizing = false; } deferral.Complete(); } }