コード例 #1
0
        public void TestAtMapManyKasterArgumentNullExceptionHvisDomainObjectsErNull()
        {
            var objectMapper = MockRepository.GenerateMock <IObjectMapper>();
            var queryHandler = new MyQueryHandler(objectMapper);

            Assert.That(queryHandler, Is.Not.Null);

            IEnumerable <Regnskab> regnskaber = null;

            Assert.Throws <ArgumentNullException>(() => queryHandler.MapMany <Regnskab, RegnskabslisteView>(regnskaber));
        }
コード例 #2
0
        public void TestAtMapManyMapperDomainObjectsTilViews()
        {
            var fixture = new Fixture();

            var objectMapper = MockRepository.GenerateMock <IObjectMapper>();

            objectMapper.Expect(
                m =>
                m.Map <IEnumerable <Regnskab>, IEnumerable <RegnskabslisteView> >(Arg <IEnumerable <Regnskab> > .Is.NotNull))
            .Return(fixture.CreateMany <RegnskabslisteView>(3));
            var queryHandler = new MyQueryHandler(objectMapper);

            Assert.That(queryHandler, Is.Not.Null);

            var views = queryHandler.MapMany <Regnskab, RegnskabslisteView>(fixture.CreateMany <Regnskab>(3));

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

            objectMapper.AssertWasCalled(
                m =>
                m.Map <IEnumerable <Regnskab>, IEnumerable <RegnskabslisteView> >(Arg <IEnumerable <Regnskab> > .Is.NotNull));
        }