public async Task DeleteDatabaseWithOpenConnection() { var name = "ToDelete"; var connectionString = await instance.CreateDatabaseFromTemplate(name); await using SqlConnection connection = new(connectionString); await connection.OpenAsync(); await instance.DeleteDatabase(name); var deletedState = await instance.ReadDatabaseState(name); SqlRecording.StartRecording(); await instance.CreateDatabaseFromTemplate(name); var entries = SqlRecording.FinishRecording(); var createdState = await instance.ReadDatabaseState(name); await Verifier.Verify(new { entries, deletedState, createdState }); }
protected Task VerifyUpdate(Action <NodaTimeTypes> mutator, [CallerFilePath] string sourceFile = "") { SqlRecording.StartRecording(); mutator(Db.NodaTimeTypes.Single()); Db.SaveChanges(); return(Verifier.Verify(SqlRecording.FinishRecording(), sourceFile: sourceFile)); }
public async Task RecordingSpecific() { await using var database = await sqlInstance.Build(); var connectionString = database.ConnectionString; #region RecordingSpecific await using SqlConnection connection = new(connectionString); await connection.OpenAsync(); SqlRecording.StartRecording(); await using var command = connection.CreateCommand(); command.CommandText = "select Value from MyTable"; var value = await command.ExecuteScalarAsync(); var entries = SqlRecording.FinishRecording(); //TODO: optionally filter the results await Verifier.Verify(new { value, sql = entries }); #endregion }
public async Task DeleteDatabase() { await instance.CreateDatabaseFromTemplate("ToDelete"); SqlRecording.StartRecording(); await instance.DeleteDatabase("ToDelete"); var entries = SqlRecording.FinishRecording(); await Verifier.Verify(entries); }
public async Task WithRebuild() { Wrapper instance2 = new(s => new SqlConnection(s), "WrapperTests", DirectoryFinder.Find("WrapperTests")); SqlRecording.StartRecording(); instance2.Start(timestamp, _ => throw new()); await instance2.AwaitStart(); var entries = SqlRecording.FinishRecording(); await Verifier.Verify(entries); }
public async Task CreateDatabase() { SqlRecording.StartRecording(); await instance.CreateDatabaseFromTemplate("CreateDatabase"); var entries = SqlRecording.FinishRecording(); await Verifier.Verify( new { entries, state = await instance.ReadDatabaseState("CreateDatabase") }); }
public async Task RecordingError() { await using var database = await sqlInstance.Build(); await using SqlConnection connection = new(database.ConnectionString); await connection.OpenAsync(); SqlRecording.StartRecording(); await using var command = connection.CreateCommand(); command.CommandText = "select * from MyTabl2e"; try { await using var dataReader = await command.ExecuteReaderAsync(); } catch { } var commands = SqlRecording.FinishRecording(); await Verifier.Verify(commands) .ScrubLinesContaining("HelpLink.ProdVer"); }
protected Task VerifyQuery(Expression <Func <T, bool> > predicate, [CallerFilePath] string sourceFile = "") { SqlRecording.StartRecording(); _ = Query.Single(predicate); return(Verifier.Verify(SqlRecording.FinishRecording(), sourceFile: sourceFile)); }