-
Notifications
You must be signed in to change notification settings - Fork 543
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 (#5159)
- Loading branch information
Showing
2 changed files
with
133 additions
and
2 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
115 changes: 115 additions & 0 deletions
115
tests/Aspire.Hosting.Kafka.Tests/KafkaPublicApiTests.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,115 @@ | ||
// 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.Kafka.Tests; | ||
|
||
public class KafkaPublicApiTests | ||
{ | ||
[Fact] | ||
public void AddKafkaContainerShouldThrowWhenBuilderIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = null!; | ||
const string name = "Kafka"; | ||
|
||
var action = () => builder.AddKafka(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddKafkaContainerShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = DistributedApplication.CreateBuilder([]); | ||
string name = null!; | ||
|
||
var action = () => builder.AddKafka(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataVolumeShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<KafkaServerResource> builder = null!; | ||
|
||
var action = () => builder.WithDataVolume(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<KafkaServerResource> builder = null!; | ||
const string source = "/Kafka/data"; | ||
|
||
var action = () => builder.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenSourceIsNull() | ||
{ | ||
var builderResource = TestDistributedApplicationBuilder.Create(); | ||
var Kafka = builderResource.AddKafka("Kafka"); | ||
string source = null!; | ||
|
||
var action = () => Kafka.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(source), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithKafkaUIShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<KafkaServerResource> builder = null!; | ||
|
||
var action = () => builder.WithKafkaUI(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithHostPortShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<KafkaUIContainerResource> builder = null!; | ||
|
||
var action = () => builder.WithHostPort(9936); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void CtorKafkaServerResourceShouldThrowWhenNameIsNull() | ||
{ | ||
string name = null!; | ||
|
||
var action = () => new KafkaServerResource(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void CtorKafkaUIContainerResourceShouldThrowWhenNameIsNull() | ||
{ | ||
string name = null!; | ||
|
||
var action = () => new KafkaUIContainerResource(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
} |