public void ConnectionTest() { using (TravelTimeDBContext context = new TravelTimeDBContext(new DbContextOptionsBuilder <TravelTimeDBContext>().UseNpgsql(this.connectionstring).Options)) { try { if (!(context.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists()) { throw new Exception("db does ont exist"); } } catch (Exception ex) { Assert.IsTrue(false, ex.Message); } } }
public void QueryTest() { using (TravelTimeDBContext context = new TravelTimeDBContext(new DbContextOptionsBuilder <TravelTimeDBContext>().UseNpgsql(this.connectionstring).Options)) { try { var testQuery = context.TravelTime.ToList(); Assert.IsNotNull(testQuery, testQuery.Count.ToString()); } catch (Exception ex) { Assert.IsTrue(false, ex.Message); } finally { } } }