public void DataStoreExecutesTheExpectedCommandToSearchTelemetryEventsInTheDatabaseWhenAFilterIsProvided2() { TestSqlTelemetryDataStore dataStore = new TestSqlTelemetryDataStore("Any connection string"); MySqlConnection connection = new MySqlConnection("Server=AnyServer;Database=AnyDatabase;Port=1234"); MySqlCommand command = dataStore.CreateTelemetrySearchCommand(connection, new FilterOptions("AnyEventName", null, true)); Assert.AreEqual( RemoveWhitespace( @"SELECT Timestamp, EventName, CorrelationId, Context FROM TelemetryEvents WHERE 1 AND EventName = 'AnyEventName' AND CorrelationId = ( SELECT CorrelationId FROM TelemetryEvents WHERE EventName = 'AnyEventName' ORDER BY Id DESC LIMIT 1 ) ORDER BY TIMESTAMP DESC"), RemoveWhitespace(command.CommandText)); Assert.AreEqual(CommandType.Text, command.CommandType); Assert.AreEqual(0, command.Parameters.Count); }
public void SetupTest() { this.dataStore = new TestSqlTelemetryDataStore("Any"); this.mockConnection = new Mock <IDbConnection>(); this.mockCommand = new Mock <IDbCommand>(); this.mockCommandParameters = new Mock <IDataParameterCollection>(); }
public void DataStoreExecutesTheExpectedCommandToWriteTelemetryEventsToTheDatabase() { TestSqlTelemetryDataStore dataStore = new TestSqlTelemetryDataStore("Any connection string"); MySqlConnection connection = new MySqlConnection("Server=AnyServer;Database=AnyDatabase;Port=1234"); MySqlCommand command = dataStore.CreateTelemetryInsertCommand( connection, new TelemetryEvent <string>("AnyEvent", Guid.NewGuid(), DateTime.Now, "AnyContext")); Assert.AreEqual( @"INSERT INTO TelemetryEvents (Timestamp, EventName, CorrelationId, Context) VALUES (@Timestamp, @EventName, @CorrelationId, @Context)", command.CommandText); Assert.AreEqual(CommandType.Text, command.CommandType); Assert.AreEqual(4, command.Parameters.Count); Assert.IsTrue(command.Parameters.Contains("@Timestamp")); Assert.IsTrue(command.Parameters.Contains("@EventName")); Assert.IsTrue(command.Parameters.Contains("@CorrelationId")); Assert.IsTrue(command.Parameters.Contains("@Context")); }