Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }