|
// 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.Garnet.Tests;
public class GarnetPublicApiTests
{
[Fact]
public void AddGarnetContainerShouldThrowWhenBuilderIsNull()
{
IDistributedApplicationBuilder builder = null!;
const string name = "Garnet";
var action = () => builder.AddGarnet(name);
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(builder), exception.ParamName);
}
[Fact]
public void AddGarnetContainerShouldThrowWhenNameIsNull()
{
var builder = TestDistributedApplicationBuilder.Create();
string name = null!;
var action = () => builder.AddGarnet(name);
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(name), exception.ParamName);
}
[Fact]
public void CtorGarnetResourceShouldThrowWhenNameIsNull()
{
string name = null!;
var action = () => new GarnetResource(name);
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(name), exception.ParamName);
}
[Fact]
public void WithDataBindMountShouldThrowWhenBuilderIsNull()
{
IResourceBuilder<GarnetResource> 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 garnet = builder.AddGarnet("Garnet");
string source = null!;
var action = () => garnet.WithDataBindMount(source);
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(source), exception.ParamName);
}
[Fact]
public void WithDataVolumeShouldThrowWhenBuilderIsNull()
{
IResourceBuilder<GarnetResource> builder = null!;
var action = () => builder.WithDataVolume();
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(builder), exception.ParamName);
}
[Fact]
public void WithPersistenceShouldThrowWhenBuilderIsNull()
{
IResourceBuilder<GarnetResource> builder = null!;
var action = () => builder.WithPersistence();
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(builder), exception.ParamName);
}
}
|