/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="dbContext"></param>
        /// <param name="configuration"></param>
        public DataStorageController(ILogger <DataStorageController> logger, GridBeyondDBContext dbContext, IConfiguration configuration)
        {
            _dbContext     = dbContext;
            _configuration = configuration;
            _logger        = logger;

            //Read the num elements per page
            _maxRegistersToSave = _configuration.GetValue <int>("TableElementsPerPage");
        }
        public async Task Statistics_BadConnection()
        {
            var options = new DbContextOptionsBuilder <GridBeyondDBContext>()
                          .UseSqlServer("Bad string connection").Options;

            using (var context = new GridBeyondDBContext(options))
            {
                AnalyzerController analyzer = new AnalyzerController(context);
                //var statistics = await analyzer.GetCommonStatistics();


                Assert.ThrowsAsync <ArgumentException>(() => analyzer.GetCommonStatistics());
            }
        }
        public async Task Statistics_FullDatabase()
        {
            var options = new DbContextOptionsBuilder <GridBeyondDBContext>()
                          .UseSqlServer("[REAL_STRING_CONNECTION]").Options;

            using (var context = new GridBeyondDBContext(options))
            {
                AnalyzerController analyzer = new AnalyzerController(context);
                var statistics = await analyzer.GetCommonStatistics();


                Assert.IsTrue(statistics.TotalItems == 3133);
            }
        }
        public async Task Statistics_EmptyDatabase()
        {
            var options = new DbContextOptionsBuilder <GridBeyondDBContext>()
                          .UseSqlServer("[REAL_STRING_CONNECTION]").Options;

            using (var context = new GridBeyondDBContext(options))
            {
                AnalyzerController analyzer = new AnalyzerController(context);
                //var statistics = await analyzer.GetCommonStatistics();


                Assert.ThrowsAsync <InvalidOperationException>(() => analyzer.GetCommonStatistics());
            }
        }
Beispiel #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext">Database context</param>
 public AnalyzerController(GridBeyondDBContext dbContext)
 {
     _dbContext = dbContext;
 }