コード例 #1
0
        public void DBContainsQueryShouldReturnFalseIfQueryIdNotInDB(int Id, bool useAsync)
        {
            //Arrange
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: "StaticFilledQueryDB")
                          .Options;
            bool      result;
            QueryRepo qRepo;

            //Act
            using (var context = new Project2DBContext(options))
            {
                qRepo = new QueryRepo(context);
                if (useAsync)
                {
                    result = qRepo.DBContainsQueryAsync(Id).Result;
                }
                else
                {
                    result = qRepo.DBContainsQuery(Id);
                }
            }
            //Assert
            Assert.False(result);
        }
コード例 #2
0
        public void DBContainsQueryShouldReturnFalseIfIfDBIsEmpty(int Id, bool useAsync)
        {
            //Arrange
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: "EmptyQueryDB3")
                          .Options;
            bool      result;
            QueryRepo qRepo;

            //Act
            using (var context = new Project2DBContext(options))
            {
                qRepo = new QueryRepo(context);
                if (useAsync)
                {
                    result = qRepo.DBContainsQueryAsync(Id).Result;
                }
                else
                {
                    result = qRepo.DBContainsQuery(Id);
                }
            }
            //If exception is throw, test will exit before reaching Assert
            //Assert
            Assert.False(result);
        }