public void TestAtSystemGetAllHenterSystemer()
        {
            IEnumerable <SystemProxy> systemProxyCollection = _fixture.CreateMany <SystemProxy>(_random.Next(5, 10)).ToList();
            IMySqlDataProvider        mySqlDataProvider     = CreateMySqlDataProvider(systemProxyCollection);

            IFællesRepository sut = new FællesRepository(CreateChannelFactory(), mySqlDataProvider, CreateDomainObjectBuilder());

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

            IEnumerable <ISystem> result = sut.SystemGetAll();

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

            IDbCommandTestExecutor expectedCommandTester = new DbCommandTestBuilder("SELECT SystemNo,Title,Properties FROM Systems ORDER BY SystemNo").Build();

            mySqlDataProvider.AssertWasCalled(m => m.GetCollection <SystemProxy>(Arg <MySqlCommand> .Matches(cmd => expectedCommandTester.Run(cmd))), opt => opt.Repeat.Once());
        }
示例#2
0
        /// <summary>
        /// Henter og returnerer et givent system under OSWEBDB.
        /// </summary>
        /// <param name="nummer">Unik identifikation af systemet.</param>
        /// <returns>System under OSWEBDB.</returns>
        public virtual ISystem SystemGetByNummer(int nummer)
        {
            var systemlisteHelper = new SystemlisteHelper(FællesRepository.SystemGetAll());

            return(systemlisteHelper.GetById(nummer));
        }
        public void TestAtSystemGetAllKasterIntranetRepositoryExceptionVedException()
        {
            Exception          exception         = _fixture.Create <Exception>();
            IMySqlDataProvider mySqlDataProvider = CreateMySqlDataProvider(exception: exception);

            IFællesRepository sut = new FællesRepository(CreateChannelFactory(), mySqlDataProvider, CreateDomainObjectBuilder());

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.SystemGetAll());

            TestHelper.AssertIntranetRepositoryExceptionIsValid(result, exception, ExceptionMessage.RepositoryError, "SystemGetAll", exception.Message);
        }
        public void TestAtSystemGetAllKasterIntranetRepositoryExceptionVedIntranetRepositoryException()
        {
            IntranetRepositoryException intranetRepositoryException = _fixture.Create <IntranetRepositoryException>();
            IMySqlDataProvider          mySqlDataProvider           = CreateMySqlDataProvider(exception: intranetRepositoryException);

            IFællesRepository sut = new FællesRepository(CreateChannelFactory(), mySqlDataProvider, CreateDomainObjectBuilder());

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

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.SystemGetAll());

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