public void TestAtKalenderbrugereHentes()
        {
            var query = new KalenderbrugereGetQuery
            {
                System = 1
            };
            var result = _service.KalenderbrugereGet(query);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.GreaterThan(0));
        }
Пример #2
0
        /// <summary>
        /// Henter og returnerer kalenderbrugere til et givent system under OSWEBDB.
        /// </summary>
        /// <param name="query">Foresprøgelse efter kalenderbrugere til et givent system under OSWEBDB.</param>
        /// <returns>Liste indeholdende kalenderbrugere til systemet under OSWEBDB.</returns>
        public IEnumerable <KalenderbrugerView> Query(KalenderbrugereGetQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var system  = SystemGetByNummer(query.System);
            var brugere = KalenderRepository.BrugerGetAllBySystem(system.Nummer);

            return(MapMany <IBruger, KalenderbrugerView>(brugere));
        }
Пример #3
0
        public void TestAtKalenderbrugereHentes()
        {
            var client = _channelFactory.CreateChannel <IKalenderService>(ClientEndpointName);

            try
            {
                var query = new KalenderbrugereGetQuery
                {
                    System = 1
                };
                var result = client.KalenderbrugereGet(query);
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.GreaterThan(0));
            }
            finally
            {
                ChannelTools.CloseChannel(client);
            }
        }
Пример #4
0
 public IEnumerable <KalenderbrugerView> KalenderbrugereGet(KalenderbrugereGetQuery query)
 {
     try
     {
         return(_queryBus.Query <KalenderbrugereGetQuery, IEnumerable <KalenderbrugerView> >(query));
     }
     catch (IntranetRepositoryException ex)
     {
         throw CreateIntranetRepositoryFault(ex);
     }
     catch (IntranetBusinessException ex)
     {
         throw CreateIntranetBusinessFault(ex);
     }
     catch (IntranetSystemException ex)
     {
         throw CreateIntranetSystemFault(ex);
     }
     catch (Exception ex)
     {
         throw CreateIntranetSystemFault(ex);
     }
 }
Пример #5
0
        public void TestAtQueryHenterKalenderbrugere()
        {
            var fixture = new Fixture();

            fixture.Customize <ISystem>(e => e.FromFactory(() =>
            {
                var system = MockRepository.GenerateMock <ISystem>();
                system.Expect(m => m.Nummer)
                .Return(fixture.Create <int>())
                .Repeat.Any();
                return(system);
            }));
            var systemer         = fixture.CreateMany <ISystem>(4).ToList();
            var fællesRepository = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepository.Expect(m => m.SystemGetAll())
            .Return(systemer);
            fixture.Inject(fællesRepository);

            fixture.Customize <IBruger>(e => e.FromFactory(() =>
            {
                var bruger = MockRepository.GenerateMock <IBruger>();
                bruger.Expect(m => m.System)
                .Return(systemer.ElementAt(1))
                .Repeat.Any();
                bruger.Expect(m => m.Id)
                .Return(fixture.Create <int>())
                .Repeat.Any();
                bruger.Expect(m => m.Initialer)
                .Return(fixture.Create <string>())
                .Repeat.Any();
                bruger.Expect(m => m.Navn)
                .Return(fixture.Create <string>())
                .Repeat.Any();
                return(bruger);
            }));
            var kalenderRepository = MockRepository.GenerateMock <IKalenderRepository>();

            kalenderRepository.Expect(m => m.BrugerGetAllBySystem(Arg <int> .Is.Equal(systemer.ElementAt(1).Nummer)))
            .Return(fixture.CreateMany <IBruger>(7).ToList());
            fixture.Inject(kalenderRepository);

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

            objectMapper.Expect(
                m => m.Map <IEnumerable <IBruger>, IEnumerable <KalenderbrugerView> >(Arg <IEnumerable <IBruger> > .Is.NotNull))
            .Return(fixture.CreateMany <KalenderbrugerView>(7));
            fixture.Inject(objectMapper);

            var queryHandler = fixture.Create <KalenderbrugereGetQueryHandler>();

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

            var query = new KalenderbrugereGetQuery
            {
                System = systemer.ElementAt(1).Nummer
            };
            var result = queryHandler.Query(query);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.EqualTo(7));

            fællesRepository.AssertWasCalled(m => m.SystemGetAll());
            kalenderRepository.Expect(m => m.BrugerGetAllBySystem(Arg <int> .Is.Equal(systemer.ElementAt(1).Nummer)));
            objectMapper.AssertWasCalled(
                m => m.Map <IEnumerable <IBruger>, IEnumerable <KalenderbrugerView> >(Arg <IEnumerable <IBruger> > .Is.NotNull));
        }