• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davewalker5 / ADS-B-BaseStationReader / 17944056005

23 Sep 2025 10:54AM UTC coverage: 94.986% (+16.6%) from 78.433%
17944056005

push

github

web-flow
Merge pull request #49 from davewalker5/position-recording-enhancements

Position recording enhancements

491 of 570 branches covered (86.14%)

Branch coverage included in aggregate %.

79 of 95 new or added lines in 9 files covered. (83.16%)

4 existing lines in 2 files now uncovered.

1839 of 1883 relevant lines covered (97.66%)

52.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.45
/src/BaseStationReader.Data/BaseStationReaderDbContextFactory.cs
1
using Microsoft.EntityFrameworkCore;
2
using Microsoft.EntityFrameworkCore.Design;
3
using Microsoft.Extensions.Configuration;
4
using System.Diagnostics.CodeAnalysis;
5

6
namespace BaseStationReader.Data
7
{
8
    public class BaseStationReaderDbContextFactory : IDesignTimeDbContextFactory<BaseStationReaderDbContext>
9
    {
10
        private const string DefaultSettingsFile = "appsettings.json";
11

12
        /// <summary>
13
        /// Create a context for the real database 
14
        /// </summary>
15
        /// <param name="args"></param>
16
        /// <param name="defaultConfigFile"></param>
17
        /// <returns></returns>
18
        [ExcludeFromCodeCoverage]
19
        public BaseStationReaderDbContext CreateDbContext(string[] args)
20
        {
21
            // Get the path to the configuration file
22
            var configPath = GetDevelopmentConfigFileName(DefaultSettingsFile);
23

24
            // Construct a configuration object that contains the key/value pairs from the settings file
25
            // at the root of the main applicatoin
26
            IConfigurationRoot configuration = new ConfigurationBuilder()
27
                                                    .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
28
                                                    .AddJsonFile(configPath)
29
                                                    .Build();
30

31
            // Use the configuration object to read the connection string
32
            var optionsBuilder = new DbContextOptionsBuilder<BaseStationReaderDbContext>();
33
            optionsBuilder.UseSqlite(configuration.GetConnectionString("BaseStationReaderDB"));
34

35
            // Construct and return a database context
36
            return new BaseStationReaderDbContext(optionsBuilder.Options);
37
        }
38

39
        /// <summary>
40
        /// Create an in-memory context for unit testing
41
        /// </summary>
42
        /// <returns></returns>
43
        public static BaseStationReaderDbContext CreateInMemoryDbContext()
44
        {
77✔
45
            var optionsBuilder = new DbContextOptionsBuilder<BaseStationReaderDbContext>();
77✔
46
            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
77✔
47
            return new BaseStationReaderDbContext(optionsBuilder.Options);
77✔
48
        }
77✔
49

50
        /// <summary>
51
        /// Construct the development config file given a production config file name
52
        /// </summary>
53
        /// <param name=""></param>
54
        /// <returns></returns>
55
        private string GetDevelopmentConfigFileName(string jsonFileName)
NEW
56
        {
×
57
            // See if a development configuration file exists and, if so, use that in place of the
58
            // file provided. For example, if the supplied file name is "appsettings.json", the development
59
            // version is "appsettings.Development.json"
NEW
60
            var fileName = Path.GetFileNameWithoutExtension(jsonFileName);
×
NEW
61
            var extension = Path.GetExtension(jsonFileName);
×
NEW
62
            var developmentConfigPath = $"{fileName}.Development{extension}";
×
NEW
63
            return developmentConfigPath;
×
NEW
64
        }
×
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc