-
Notifications
You must be signed in to change notification settings - Fork 465
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.MongoDB.Driver (#5171)
- Loading branch information
Showing
2 changed files
with
89 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
82 changes: 82 additions & 0 deletions
82
tests/Aspire.MongoDB.Driver.Tests/MongoDBDriverPublicApiTests.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,82 @@ | ||
// 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.MongoDB.Driver.Tests; | ||
|
||
public class MongoDBClientPublicApiTests | ||
{ | ||
[Fact] | ||
public void AddMongoDBClientShouldThrowWhenBuilderIsNull() | ||
{ | ||
IHostApplicationBuilder builder = null!; | ||
var connectionName = "mongodb"; | ||
|
||
var action = () => builder.AddMongoDBClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddMongoDBClientShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
string connectionName = null!; | ||
|
||
var action = () => builder.AddMongoDBClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(connectionName), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddMongoDBClientShouldThrowWhenNameIsEmpty() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
string connectionName = ""; | ||
|
||
var action = () => builder.AddMongoDBClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentException>(action); | ||
Assert.Equal(nameof(connectionName), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedMongoDBClientShouldThrowWhenBuilderIsNull() | ||
{ | ||
IHostApplicationBuilder builder = null!; | ||
var connectionName = "mongodb"; | ||
|
||
var action = () => builder.AddKeyedMongoDBClient(connectionName); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedMongoDBClientShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
string name = null!; | ||
|
||
var action = () => builder.AddKeyedMongoDBClient(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKeyedMongoDBClientShouldThrowWhenNameIsEmpty() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
string name = ""; | ||
|
||
var action = () => builder.AddKeyedMongoDBClient(name); | ||
|
||
var exception = Assert.Throws<ArgumentException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
} |