コード例 #1
0
        public void GetQueriesShouldNotThrowExceptionIfDBIsEmpty()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: "EmptyDB1")
                          .Options;

            bool      result = true;
            QueryRepo qRepo;

            //Act
            using (var context = new Project2DBContext(options))
            {
                qRepo = new QueryRepo(context);
                try
                {
                    qRepo.GetQueries();
                }
                catch
                {
                    result = false;
                }
            }
            //Assert
            Assert.True(result);
        }
コード例 #2
0
        public void GetQueriesShouldReturnAListWithProperNumberOfQueriess()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: "StaticFilledQueryDB")
                          .Options;
            QueryRepo    qRepo;
            List <Query> qList;

            //Act
            using (var context = new Project2DBContext(options))
            {
                qRepo = new QueryRepo(context);
                qList = qRepo.GetQueries().ToList();
            }
            //Assert
            Assert.Equal(15, qList.Count);
        }