Beispiel #1
0
        public void TestAtKontogruppeGetAllHenterAlleKontogrupper()
        {
            var fixture = new Fixture();

            var mocker  = new MockRepository();
            var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) });

            service.Expect(m => m.KontogruppeGetAll(Arg <KontogruppeGetAllQuery> .Is.Anything))
            .Return(fixture.CreateMany <KontogruppeView>(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));

            var repository   = new FinansstyringRepository(channelFactory, domainObjectBuilder);
            var kontogrupper = repository.KontogruppeGetAll();

            Assert.That(kontogrupper, Is.Not.Null);
            Assert.That(kontogrupper.Count(), Is.EqualTo(3));

            domainObjectBuilder.AssertWasCalled(
                m => m.BuildMany <KontogruppeView, Kontogruppe>(Arg <IEnumerable <KontogruppeView> > .Is.NotNull));
        }
Beispiel #2
0
        public void TestAtKontogruppeGetAllKasterIntranetRepositoryExceptionVedException()
        {
            var fixture = new Fixture();

            var mocker  = new MockRepository();
            var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) });

            service.Expect(m => m.KontogruppeGetAll(Arg <KontogruppeGetAllQuery> .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.KontogruppeGetAll());
        }