Skip to content

Commit

Permalink
ensure no duplicates added
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebo committed Jan 16, 2024
1 parent ff977fd commit b287533
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ public void Test_TeamsAdapter_HasDefaultHeaders()
Assert.NotNull(client);
Assert.True(client.DefaultRequestHeaders.UserAgent.Contains(productInfo));
}

[Fact]
public void Test_TeamsAdapter_NoDuplicateDefaultHeaders()
{
string version = Assembly.GetAssembly(typeof(TeamsAdapter))?.GetName().Version?.ToString() ?? "";
ProductInfoHeaderValue productInfo = new("teamsai-dotnet", version);
TeamsAdapter adapter = new(new TeamsHttpClientFactory());
Assert.NotNull(adapter.HttpClientFactory);

HttpClient client = adapter.HttpClientFactory.CreateClient();
Assert.NotNull(client);
Assert.True(client.DefaultRequestHeaders.UserAgent.Contains(productInfo));
Assert.True(client.DefaultRequestHeaders.UserAgent.Count == 1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class TeamsAdapter : CloudAdapter
/// <summary>
/// Initializes a new instance of the <see cref="TeamsAdapter"/> class. (Public cloud. No auth. For testing.)
/// </summary>
public TeamsAdapter() : base()
public TeamsAdapter(IHttpClientFactory? httpClientFactory = null) : base()
{
HttpClientFactory = new TeamsHttpClientFactory();
HttpClientFactory = new TeamsHttpClientFactory(httpClientFactory);
}

/// <summary>
Expand Down

0 comments on commit b287533

Please sign in to comment.