mirror of https://github.com/dapr/dotnet-sdk.git
parent
776156298e
commit
9fd1900e59
|
|
@ -42,7 +42,7 @@ namespace Dapr.Client
|
|||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentException("The value cannot be null or empty", nameof(name));
|
||||
throw new ArgumentException("The value cannot be null or empty", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
namespace Dapr.Client.Test
|
||||
{
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
public class ArgumentVerifierTest
|
||||
{
|
||||
[Fact]
|
||||
public void ThrowIfNull_RespectsArgumentName()
|
||||
{
|
||||
var ex = Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
ArgumentVerifier.ThrowIfNull(null, "args");
|
||||
});
|
||||
|
||||
Assert.Contains("args", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowIfNullOrEmpty_RespectsArgumentName_WhenValueIsNull()
|
||||
{
|
||||
var ex = Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
ArgumentVerifier.ThrowIfNullOrEmpty(null, "args");
|
||||
});
|
||||
|
||||
Assert.Contains("args", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowIfNullOrEmpty_RespectsArgumentName_WhenValueIsEmpty()
|
||||
{
|
||||
var ex = Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
ArgumentVerifier.ThrowIfNullOrEmpty(string.Empty, "args");
|
||||
});
|
||||
|
||||
Assert.Contains("args", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue