Esempio n. 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());
        }
Esempio n. 2
0
        public void TestAtAftaleGetAllBySystemHenterAftaler()
        {
            var aftaler = _kalenderRepository.AftaleGetAllBySystem(1, new DateTime(2010, 1, 1));

            Assert.That(aftaler, Is.Not.Null);
            Assert.That(aftaler.Count(), Is.GreaterThan(0));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
        }