Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }