-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding public API test coverage for Aspire.Elastic.Clients.Elasticsea…
…rch (#5169)
- Loading branch information
Showing
2 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
tests/Aspire.Elastic.Clients.Elasticsearch.Tests/ElasticsearchClientPublicApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Hosting; | ||
using Xunit; | ||
|
||
namespace Aspire.Elastic.Clients.Elasticsearch.Tests; | ||
|
||
public class ElasticsearchClientPublicApiTests | ||
{ | ||
[Fact] | ||
public void AddElasticsearchClientShouldThrowWhenBuilderIsNull() | ||
{ | ||
IHostApplicationBuilder builder = null!; | ||
|
||
var connectionName = "elasticseach"; | ||
|
||
var action = () => builder.AddElasticsearchClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddElasticsearchClientShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
|
||
string connectionName = null!; | ||
|
||
var action = () => builder.AddElasticsearchClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(connectionName), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddElasticsearchClientShouldThrowWhenNameIsEmpty() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
|
||
string connectionName = ""; | ||
|
||
var action = () => builder.AddElasticsearchClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentException>(action); | ||
Assert.Equal(nameof(connectionName), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedElasticsearchClientShouldThrowWhenBuilderIsNull() | ||
{ | ||
IHostApplicationBuilder builder = null!; | ||
|
||
var connectionName = "elasticseach"; | ||
|
||
var action = () => builder.AddKeyedElasticsearchClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedElasticsearchClientShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
|
||
string name = null!; | ||
|
||
var action = () => builder.AddKeyedElasticsearchClient(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedElasticsearchClientShouldThrowWhenNameIsEmpty() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
|
||
string name = ""; | ||
|
||
var action = () => builder.AddKeyedElasticsearchClient(name); | ||
|
||
var exception = Assert.Throws<ArgumentException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
} |