public void ShouldBeAbleToExplicitlyStart() { // Arrange using var arena = new TestArena("-e", "mysql"); // Act arena.WaitForProgramToListen(); var interestingLine = arena.StdOut.FirstOrDefault( line => line.StartsWith( "connection string", StringComparison.InvariantCultureIgnoreCase )); Expect(interestingLine) .Not.To.Be.Null( "TempDb runner should emit the connection string on stdout" ); var connectionString = interestingLine.Split(':') .Skip(1) .JoinWith(":") .Trim(); using (var connection = new MySqlConnection(connectionString)) { // Assert Expect(() => connection.Open()) .Not.To.Throw(); } }
public void ShouldBeAbleToStopViaStdIn() { // Arrange using (var arena = new TestArena("-e", "localdb")) { // Act arena.WaitForProgramToListen(); var interestingLine = arena.StdOut.FirstOrDefault( line => line.StartsWith( "connection string", StringComparison.InvariantCultureIgnoreCase )); Expect(interestingLine) .Not.To.Be.Null( "TempDb runner should emit the connection string on stdout" ); var connectionString = interestingLine.Split(':') .Skip(1) .JoinWith(":") .Trim(); using (var connection = new SqlConnection(connectionString)) { // Assert Expect(() => connection.Open()) .Not.To.Throw(); } arena.WriteStdIn("stop"); arena.WaitForProgramToExit(); using (var dead = new SqlConnection(connectionString)) { Expect(() => dead.Open()) .To.Throw <SqlException>(); } } }