-
Notifications
You must be signed in to change notification settings - Fork 479
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.Hosting.Nats (#5129)
* CA1062#Aspire.Hosting.Nats * Remove Address
- Loading branch information
Showing
3 changed files
with
121 additions
and
6 deletions.
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
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
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,93 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.ApplicationModel; | ||
using Aspire.Hosting.Utils; | ||
using Xunit; | ||
|
||
namespace Aspire.Hosting.Nats.Tests; | ||
|
||
public class NatsPublicApiTests | ||
{ | ||
[Fact] | ||
public void AddNatsContainerShouldThrowWhenBuilderIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = null!; | ||
const string name = "Nats"; | ||
|
||
var action = () => builder.AddNats(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddNatsContainerShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
string name = null!; | ||
|
||
var action = () => builder.AddNats(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithJetStreamShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<NatsServerResource> builder = null!; | ||
|
||
var action = () => builder.WithJetStream(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataVolumeShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<NatsServerResource> builder = null!; | ||
|
||
var action = () => builder.WithDataVolume(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<NatsServerResource> builder = null!; | ||
const string source = "/data"; | ||
|
||
var action = () => builder.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenSourceIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
var nats = builder.AddNats("Nats"); | ||
string source = null!; | ||
|
||
var action = () => nats.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(source), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void CtorNatsServerResourceShouldThrowWhenNameIsNull() | ||
{ | ||
string name = null!; | ||
|
||
var action = () => new NatsServerResource(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
} |