// dotnet test --filter "FullyQualifiedName=damper_dan_client.tests.TesterTests.GetDampersTest" public async Task GetDampersTest() { var optionsBuilder = new DbContextOptionsBuilder <DamperContext>(); optionsBuilder.UseMySql("Server=localhost;Database=tstrat_damper;User=root;Password=;"); using (DamperContext ctx = new DamperContext(optionsBuilder.Options)) { Dampers jc = new TesterController(ctx); (await jc.GetDampers()).ForEach(s => Console.WriteLine(s.alias_id)); } }
// dotnet test --filter "FullyQualifiedName=damper_dan_client.tests.FacilitiesEngineerTest.GetBuildingsTest" public async Task GetBuildingsTest() { Console.WriteLine("FacilitiesEngineer - Getting Buildings"); var optionsBuilder = new DbContextOptionsBuilder <DamperContext>(); optionsBuilder.UseMySql("Server=localhost;Database=tstrat_damper;User=root;Password=;"); using (DamperContext ctx = new DamperContext(optionsBuilder.Options)) { Dampers d = new FacilitiesController(ctx); (await d.GetBuildings()).ForEach(s => Console.WriteLine(s.alias_id)); } }
// dotnet test --filter "FullyQualifiedName=damper_dan_client.tests.MysqlTests.BasicConnectionTest" public void BasicConnectionTest() { // Within ASP Framework, the common use is DBContextPooling // Using Dependency Injection from the ServiceContainer, basic configuration // is done in the startup.cs file. var optionsBuilder = new DbContextOptionsBuilder <DamperContext>(); optionsBuilder.UseMySql("Server=localhost;Database=tstrat_damper;User=root;Password=;"); using (DamperContext ctx = new DamperContext(optionsBuilder.Options)) { ctx.Dampertest.Select(x => x.alias_id).Take(3).ToList().ForEach(s => Console.WriteLine(s)); } }
// dotnet test --filter "FullyQualifiedName=damper_dan_client.tests.FacilitiesEngineerTest.GetDampersByBuildingTest" public async Task GetDampersByBuildingTest() { Console.WriteLine("FacilitiesEngineer - Getting Dampers by Building"); var optionsBuilder = new DbContextOptionsBuilder <DamperContext>(); optionsBuilder.UseMySql("Server=localhost;Database=tstrat_damper;User=root;Password=;"); using (DamperContext ctx = new DamperContext(optionsBuilder.Options)) { Dampers d = new FacilitiesController(ctx); var building = (await d.GetDampers())[1]; // Let just get the first building on the list (await d.GetDampersByBuilding(building.id)).ForEach(s => Console.WriteLine(s.alias_id)); } }
public TesterController(DamperContext ctx) { this.ctx = ctx; }
public JachoController(DamperContext ctx) { this.ctx = ctx; }
public FacilitiesController(DamperContext ctx) { this.ctx = ctx; }