Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove Address
  • Loading branch information
Zombach committed Aug 1, 2024
commit 2fd846ab01d1ed6e06aade4f87e7cd0d3b9c5d59
12 changes: 6 additions & 6 deletions src/Aspire.Hosting.Nats/NatsServerResource.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// A resource that represents a NATS server container.
/// </summary>
/// <param name="name">The name of the resource.</param>

public class NatsServerResource(string name) : ContainerResource(PassThroughNonNull(name)), IResourceWithConnectionString
public class NatsServerResource(string name) : ContainerResource(ThrowIfNull(name)), IResourceWithConnectionString
{
internal const string PrimaryEndpointName = "tcp";
internal const string PrimaryNatsSchemeName = "nats";
Expand All @@ -27,9 +30,6 @@ public class NatsServerResource(string name) : ContainerResource(PassThroughNonN
ReferenceExpression.Create(
$"{PrimaryNatsSchemeName}://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

private static string PassThroughNonNull(string name)
{
ArgumentNullException.ThrowIfNull(name);
return name;
}
private static string ThrowIfNull([NotNull] string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
=> argument ?? throw new ArgumentNullException(paramName);
}
8 changes: 0 additions & 8 deletions tests/Aspire.Hosting.Nats.Tests/NatsPublicApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace Aspire.Hosting.Nats.Tests;

public class NatsPublicApiTests
{
#region NatsBuilderExtensions

[Fact]
public void AddNatsContainerShouldThrowWhenBuilderIsNull()
{
Expand Down Expand Up @@ -82,10 +80,6 @@ public void WithDataBindMountShouldThrowWhenSourceIsNull()
Assert.Equal(nameof(source), exception.ParamName);
}

#endregion

#region NatsServerResource

[Fact]
public void CtorNatsServerResourceShouldThrowWhenNameIsNull()
{
Expand All @@ -96,6 +90,4 @@ public void CtorNatsServerResourceShouldThrowWhenNameIsNull()
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(name), exception.ParamName);
}

#endregion
}