コード例 #1
0
        public void TestAtAftaleGetAllBySystemHenterAftaler()
        {
            IEnumerable <AftaleProxy> appointmentProxyCollection = _fixture.Build <AftaleProxy>()
                                                                   .With(m => m.FraTidspunkt, DateTime.MinValue)
                                                                   .With(m => m.TilTidspunkt, DateTime.MaxValue)
                                                                   .CreateMany(_random.Next(15, 25))
                                                                   .ToList();

            IKalenderRepository sut = CreateSut(appointmentProxyCollection);

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

            int      systemNo            = _fixture.Create <int>();
            DateTime fromDate            = DateTime.Now.AddDays(_random.Next(1, 30) * -1);
            IEnumerable <IAftale> result = sut.AftaleGetAllBySystem(systemNo, fromDate);

            // ReSharper disable PossibleMultipleEnumeration
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.Not.Empty);
            Assert.That(result, Is.EqualTo(appointmentProxyCollection));
            // ReSharper restore PossibleMultipleEnumeration

            IDbCommandTestExecutor commandTester = new DbCommandTestBuilder("SELECT ca.SystemNo,ca.CalId,ca.Date,ca.FromTime,ca.ToTime,ca.Properties,ca.Subject,ca.Note,s.Title AS SystemTitle,s.Properties AS SystemProperties FROM Calapps AS ca FORCE INDEX(IX_Calapps_SystemNo_Date) INNER JOIN Systems AS s ON s.SystemNo=ca.SystemNo WHERE ca.SystemNo=@systemNo AND ca.Date>=@date ORDER BY ca.Date DESC,ca.FromTime DESC,ca.ToTime DESC,ca.CalId DESC")
                                                   .AddSmallIntDataParameter("@systemNo", systemNo, 2)
                                                   .AddDateParameter("@date", fromDate)
                                                   .Build();

            _dataProviderMock.AssertWasCalled(m => m.GetCollection <AftaleProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once());
        }
コード例 #2
0
        public void TestAtBrugerGetAllBySystemKasterIntranetRepositoryExceptionVedException()
        {
            Exception exception = _fixture.Create <Exception>();

            IKalenderRepository sut = CreateSut(exception: exception);

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.BrugerGetAllBySystem(_fixture.Create <int>()));

            TestHelper.AssertIntranetRepositoryExceptionIsValid(result, exception, ExceptionMessage.RepositoryError, "BrugerGetAllBySystem", exception.Message);
        }
コード例 #3
0
        public void TestAtAftaleGetAllBySystemKasterIntranetRepositoryExceptionVedException()
        {
            Exception exception = _fixture.Create <Exception>();

            IKalenderRepository sut = CreateSut(exception: exception);

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.AftaleGetAllBySystem(_fixture.Create <int>(), DateTime.Now.AddDays(_random.Next(1, 30) * -1)));

            TestHelper.AssertIntranetRepositoryExceptionIsValid(result, exception, ExceptionMessage.RepositoryError, "AftaleGetAllBySystem", exception.Message);
        }
コード例 #4
0
        public void TestAtAftaleGetAllBySystemKasterIntranetRepositoryExceptionVedIntranetRepositoryException()
        {
            IntranetRepositoryException intranetRepositoryException = _fixture.Create <IntranetRepositoryException>();

            IKalenderRepository sut = CreateSut(exception: intranetRepositoryException);

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.AftaleGetAllBySystem(_fixture.Create <int>(), DateTime.Now.AddDays(_random.Next(1, 30) * -1)));

            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.EqualTo(intranetRepositoryException));
        }
コード例 #5
0
        public void TestAtBrugerGetAllBySystemKasterIntranetRepositoryExceptionVedIntranetRepositoryException()
        {
            IntranetRepositoryException intranetRepositoryException = _fixture.Create <IntranetRepositoryException>();

            IKalenderRepository sut = CreateSut(exception: intranetRepositoryException);

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.BrugerGetAllBySystem(_fixture.Create <int>()));

            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.EqualTo(intranetRepositoryException));
        }
 /// <summary>
 /// Danner basisklasse for en QueryHandler til kalenderdelen under OSWEBDB.
 /// </summary>
 /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param>
 /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param>
 /// <param name="objectMapper">Implementering af objectmapper.</param>
 protected KalenderQueryHandlerBase(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper)
     : base(objectMapper)
 {
     if (kalenderRepository == null)
     {
         throw new ArgumentNullException("kalenderRepository");
     }
     if (fællesRepository == null)
     {
         throw new ArgumentNullException("fællesRepository");
     }
     _kalenderRepository = kalenderRepository;
     _fællesRepository   = fællesRepository;
 }
コード例 #7
0
        public void TestAtAftaleGetBySystemAndIdHenterAftale()
        {
            AftaleProxy appointmentProxy = _fixture.Build <AftaleProxy>()
                                           .With(m => m.FraTidspunkt, DateTime.MinValue)
                                           .With(m => m.TilTidspunkt, DateTime.MaxValue)
                                           .Create();

            IKalenderRepository sut = CreateSut(appointmentProxy: appointmentProxy);

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

            int     systemNo = _fixture.Create <int>();
            int     calId    = _fixture.Create <int>();
            IAftale result   = sut.AftaleGetBySystemAndId(systemNo, calId);

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

            _dataProviderMock.AssertWasCalled(m => m.Get(Arg <AftaleProxy> .Matches(n => n.System != null && n.System.Nummer == systemNo && n.Id == calId)), opt => opt.Repeat.Once());
        }
コード例 #8
0
        public void TestAtBrugerGetAllBySystemHenterBrugere()
        {
            IEnumerable <BrugerProxy> calenderUserProxyCollection = _fixture.CreateMany <BrugerProxy>(_random.Next(15, 25)).ToList();

            IKalenderRepository sut = CreateSut(calenderUserProxyCollection: calenderUserProxyCollection);

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

            int systemNo = _fixture.Create <int>();
            IEnumerable <IBruger> result = sut.BrugerGetAllBySystem(systemNo);

            // ReSharper disable PossibleMultipleEnumeration
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.EqualTo(calenderUserProxyCollection));
            // ReSharper restore PossibleMultipleEnumeration

            IDbCommandTestExecutor commandTester = new DbCommandTestBuilder("SELECT cu.SystemNo,cu.UserId,cu.UserName,cu.Name,cu.Initials,s.Title,s.Properties FROM Calusers AS cu INNER JOIN Systems AS s ON s.SystemNo=cu.SystemNo WHERE cu.SystemNo=@systemNo ORDER BY cu.Name,cu.Initials,cu.UserId")
                                                   .AddSmallIntDataParameter("@systemNo", systemNo, 2)
                                                   .Build();

            _dataProviderMock.AssertWasCalled(m => m.GetCollection <BrugerProxy>(Arg <MySqlCommand> .Matches(cmd => commandTester.Run(cmd))), opt => opt.Repeat.Once());
        }
コード例 #9
0
 /// <summary>
 /// Danner basisklasse for en CommandHandler til kalenderdelen under OSWEBDB.
 /// </summary>
 /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param>
 /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param>
 /// <param name="objectMapper">Implementering af objectmapper.</param>
 /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param>
 protected KalenderCommandHandlerBase(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder)
 {
     if (kalenderRepository == null)
     {
         throw new ArgumentNullException("kalenderRepository");
     }
     if (fællesRepository == null)
     {
         throw new ArgumentNullException("fællesRepository");
     }
     if (objectMapper == null)
     {
         throw new ArgumentNullException("objectMapper");
     }
     if (exceptionBuilder == null)
     {
         throw new ArgumentNullException("exceptionBuilder");
     }
     _kalenderRepository = kalenderRepository;
     _fællesRepository   = fællesRepository;
     _objectMapper       = objectMapper;
     _exceptionBuilder   = exceptionBuilder;
 }
 /// <summary>
 /// Danner egen klasse til test af basisklasse for en QueryHandler til kalenderdelen under OSWEBDB.
 /// </summary>
 /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param>
 /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param>
 /// <param name="objectMapper">Implementering af objectmapper.</param>
 public MyKalenderQueryHandler(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper)
     : base(kalenderRepository, fællesRepository, objectMapper)
 {
 }
 /// <summary>
 /// Danner QueryHandler til håndtering af forespørgelsen: KalenderbrugerAftalerGetQuery.
 /// </summary>
 /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param>
 /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param>
 /// <param name="objectMapper">Implementering af objectmapper.</param>
 public KalenderbrugerAftalerGetQueryHandler(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper)
     : base(kalenderRepository, fællesRepository, objectMapper)
 {
 }
 /// <summary>
 /// Danner egen klasse til test af basisklasse for en CommandHandler til kalenderdelen under OSWEBDB.
 /// </summary>
 /// <param name="kalenderRepository">Implementering af repository til kalenderdelen under OSWEBDB.</param>
 /// <param name="fællesRepository">Implementering af repository til fælles elementer i domænet, såsom systemer under OSWEBDB.</param>
 /// <param name="objectMapper">Implementering af objectmapper.</param>
 /// <param name="exceptionBuilder">Implementering af en builder, der kan bygge exceptions.</param>
 public MyKalenderCommandHandler(IKalenderRepository kalenderRepository, IFællesRepository fællesRepository, IObjectMapper objectMapper, IExceptionBuilder exceptionBuilder)
     : base(kalenderRepository, fællesRepository, objectMapper, exceptionBuilder)
 {
 }
コード例 #13
0
        public void TestSetUp()
        {
            var container = ContainerFactory.Create();

            _kalenderRepository = container.Resolve <IKalenderRepository>();
        }