Skip to content

Commit 74d47eb

Browse files
committed
Require ApplicationId in AppInsights client tests
Updated AppInsightsAuthTests to require ApplicationId in connection strings and adjusted test logic accordingly. Improved GraphImportTests to handle missing cognitive config by marking sentiment assertions inconclusive instead of failing.
1 parent 838e124 commit 74d47eb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/AnalyticsEngine/Tests.UnitTests/AppInsightsAuthTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public void AppInsightsAPIClient_NullCredential_Throws()
4747
}
4848

4949
/// <summary>
50-
/// Verify AppInsightsAPIClient rejects a connection string without an InstrumentationKey.
50+
/// Verify AppInsightsAPIClient rejects a connection string without an ApplicationId.
5151
/// </summary>
5252
[TestMethod]
5353
[ExpectedException(typeof(ArgumentException))]
54-
public void AppInsightsAPIClient_ConnectionStringWithoutIKey_Throws()
54+
public void AppInsightsAPIClient_ConnectionStringWithoutApplicationId_Throws()
5555
{
5656
var credential = new ClientSecretCredential("tenant-id", "client-id", "secret");
57-
new AppInsightsAPIClient("IngestionEndpoint=https://test.in.applicationinsights.azure.com/", credential, AnalyticsLogger.ConsoleOnlyTracer());
57+
new AppInsightsAPIClient("InstrumentationKey=00000000-0000-0000-0000-000000000001;IngestionEndpoint=https://test.in.applicationinsights.azure.com/", credential, AnalyticsLogger.ConsoleOnlyTracer());
5858
}
5959

6060
/// <summary>
@@ -64,7 +64,7 @@ public void AppInsightsAPIClient_ConnectionStringWithoutIKey_Throws()
6464
public void AppInsightsAPIClient_ValidConnectionString_Constructs()
6565
{
6666
var credential = new ClientSecretCredential("tenant-id", "client-id", "secret");
67-
var connStr = "InstrumentationKey=00000000-0000-0000-0000-000000000001;IngestionEndpoint=https://test.in.applicationinsights.azure.com/;LiveEndpoint=https://test.livediagnostics.monitor.azure.com/";
67+
var connStr = "InstrumentationKey=00000000-0000-0000-0000-000000000001;IngestionEndpoint=https://test.in.applicationinsights.azure.com/;LiveEndpoint=https://test.livediagnostics.monitor.azure.com/;ApplicationId=00000000-0000-0000-0000-000000000002";
6868
using (var client = new AppInsightsAPIClient(connStr, credential, AnalyticsLogger.ConsoleOnlyTracer()))
6969
{
7070
Assert.IsNotNull(client);

src/AnalyticsEngine/Tests.UnitTests/GraphImportTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ public async Task SingleTeamSaveToSQLTest()
342342
// Check last inserted log data
343343
Assert.IsTrue(await db.TeamChannelStats.Where(l => l.Date == testDate).CountAsync() > 0, "Couldn't find any stats by test date");
344344
var lastInserted = await db.TeamChannelStats.OrderByDescending(s => s.ID).FirstOrDefaultAsync();
345-
Assert.IsTrue(lastInserted.SentimentScore.HasValue, "Last inserted log has no sentiment score");
345+
346+
if (settings.IsValidCognitiveConfig)
347+
Assert.IsTrue(lastInserted.SentimentScore.HasValue, "Last inserted log has no sentiment score");
348+
else
349+
Assert.Inconclusive("No cognitive config provided, can't test sentiment score presence or value");
346350

347351
// Last inserted log should have msg count for messages on that day only
348352
Assert.IsTrue(lastInserted.ChatsCount == channelWithMsgsOnDifferentDays.Messages
@@ -388,7 +392,12 @@ public async Task SingleTeamSaveToSQLTest()
388392
// 4th count should only include the last happy msgs - 1 log as they're all on the same day
389393
Assert.IsTrue(thirdPostTestChannelLogCount == 3, "Unexpected channel stats inserted for 2nd save of same data");
390394
var lastInsertedHappy = await db.TeamChannelStats.OrderByDescending(s => s.ID).FirstOrDefaultAsync();
391-
Assert.IsTrue(lastInsertedHappy.SentimentScore > lastInserted.SentimentScore, "Happier sentiment sentances aren't apparently more happy");
395+
396+
397+
if (settings.IsValidCognitiveConfig)
398+
Assert.IsTrue(lastInsertedHappy.SentimentScore > lastInserted.SentimentScore, "Happier sentiment sentances aren't apparently more happy");
399+
else
400+
Assert.Inconclusive("No cognitive config provided, can't test sentiment score presence or value");
392401
}
393402
}
394403

0 commit comments

Comments
 (0)