Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Linq;
using DotNetWorkQueue.Dashboard.Api.Configuration;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration
Expand All @@ -13,16 +13,16 @@ public void AddQueue_Adds_To_List()
{
var opts = new DashboardConnectionOptions();
opts.AddQueue("TestQueue");
opts.Queues.Should().HaveCount(1);
opts.Queues[0].QueueName.Should().Be("TestQueue");
Assert.AreEqual(1, (opts.Queues).Count());
Assert.AreEqual("TestQueue", opts.Queues[0].QueueName);
}

[TestMethod]
public void AddQueue_Without_Interceptors_Has_Null_Config()
{
var opts = new DashboardConnectionOptions();
opts.AddQueue("TestQueue");
opts.Queues[0].InterceptorConfiguration.Should().BeNull();
Assert.IsNull(opts.Queues[0].InterceptorConfiguration);
}

[TestMethod]
Expand All @@ -31,8 +31,8 @@ public void AddQueue_With_Interceptors_Stores_Config()
var opts = new DashboardConnectionOptions();
Action<IContainer> config = c => { };
opts.AddQueue("TestQueue", config);
opts.Queues[0].InterceptorConfiguration.Should().NotBeNull();
opts.Queues[0].InterceptorConfiguration.Should().BeSameAs(config);
Assert.IsNotNull(opts.Queues[0].InterceptorConfiguration);
Assert.AreSame(config, opts.Queues[0].InterceptorConfiguration);
}

[TestMethod]
Expand All @@ -42,18 +42,18 @@ public void AddQueue_Multiple_Queues()
opts.AddQueue("Queue1");
opts.AddQueue("Queue2");
opts.AddQueue("Queue3");
opts.Queues.Should().HaveCount(3);
Assert.AreEqual(3, (opts.Queues).Count());
}

[TestMethod]
public void AddQueueWithProfile_Stores_Profile_Name()
{
var opts = new DashboardConnectionOptions();
opts.AddQueueWithProfile("TestQueue", "encrypted");
opts.Queues.Should().HaveCount(1);
opts.Queues[0].QueueName.Should().Be("TestQueue");
opts.Queues[0].InterceptorProfile.Should().Be("encrypted");
opts.Queues[0].InterceptorConfiguration.Should().BeNull();
Assert.AreEqual(1, (opts.Queues).Count());
Assert.AreEqual("TestQueue", opts.Queues[0].QueueName);
Assert.AreEqual("encrypted", opts.Queues[0].InterceptorProfile);
Assert.IsNull(opts.Queues[0].InterceptorConfiguration);
}

[TestMethod]
Expand All @@ -65,10 +65,10 @@ public void AddQueue_With_InterceptorOptions_Stores_Options()
GZip = new GZipInterceptorOptions { MinimumSize = 200 }
};
opts.AddQueue("TestQueue", interceptors);
opts.Queues.Should().HaveCount(1);
opts.Queues[0].QueueName.Should().Be("TestQueue");
opts.Queues[0].Interceptors.Should().BeSameAs(interceptors);
opts.Queues[0].InterceptorConfiguration.Should().BeNull();
Assert.AreEqual(1, (opts.Queues).Count());
Assert.AreEqual("TestQueue", opts.Queues[0].QueueName);
Assert.AreSame(interceptors, opts.Queues[0].Interceptors);
Assert.IsNull(opts.Queues[0].InterceptorConfiguration);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNetWorkQueue.Dashboard.Api.Configuration;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration
Expand All @@ -11,32 +10,32 @@ public class DashboardInterceptorOptionsTests
public void Defaults_Are_Null()
{
var opts = new DashboardInterceptorOptions();
opts.GZip.Should().BeNull();
opts.TripleDes.Should().BeNull();
Assert.IsNull(opts.GZip);
Assert.IsNull(opts.TripleDes);
}

[TestMethod]
public void GZip_Defaults()
{
var opts = new GZipInterceptorOptions();
opts.Enabled.Should().BeTrue();
opts.MinimumSize.Should().Be(150);
Assert.IsTrue(opts.Enabled);
Assert.AreEqual(150, opts.MinimumSize);
}

[TestMethod]
public void GZip_MinimumSize_Can_Be_Set()
{
var opts = new GZipInterceptorOptions { MinimumSize = 500 };
opts.MinimumSize.Should().Be(500);
Assert.AreEqual(500, opts.MinimumSize);
}

[TestMethod]
public void TripleDes_Defaults()
{
var opts = new TripleDesInterceptorOptions();
opts.Enabled.Should().BeTrue();
opts.Key.Should().BeNull();
opts.IV.Should().BeNull();
Assert.IsTrue(opts.Enabled);
Assert.IsNull(opts.Key);
Assert.IsNull(opts.IV);
}

[TestMethod]
Expand All @@ -47,8 +46,8 @@ public void TripleDes_Can_Be_Set()
Key = "dGVzdGtleQ==",
IV = "dGVzdGl2"
};
opts.Key.Should().Be("dGVzdGtleQ==");
opts.IV.Should().Be("dGVzdGl2");
Assert.AreEqual("dGVzdGtleQ==", opts.Key);
Assert.AreEqual("dGVzdGl2", opts.IV);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Linq;
using DotNetWorkQueue.Dashboard.Api.Configuration;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration
Expand All @@ -12,22 +12,22 @@ public class DashboardOptionsTests
public void Defaults_Are_Correct()
{
var opts = new DashboardOptions();
opts.EnableSwagger.Should().BeTrue();
opts.AuthorizationPolicy.Should().BeNull();
Assert.IsTrue(opts.EnableSwagger);
Assert.IsNull(opts.AuthorizationPolicy);
}

[TestMethod]
public void EnableSwagger_Can_Be_Disabled()
{
var opts = new DashboardOptions { EnableSwagger = false };
opts.EnableSwagger.Should().BeFalse();
Assert.IsFalse(opts.EnableSwagger);
}

[TestMethod]
public void AuthorizationPolicy_Can_Be_Set()
{
var opts = new DashboardOptions { AuthorizationPolicy = "AdminOnly" };
opts.AuthorizationPolicy.Should().Be("AdminOnly");
Assert.AreEqual("AdminOnly", opts.AuthorizationPolicy);
}

[TestMethod]
Expand All @@ -36,8 +36,8 @@ public void AddInterceptorProfile_Stores_Profile()
var opts = new DashboardOptions();
Action<IContainer> action = _ => { };
opts.AddInterceptorProfile("encrypted", action);
opts.InterceptorProfiles.Should().ContainKey("encrypted");
opts.InterceptorProfiles["encrypted"].Should().BeSameAs(action);
Assert.IsTrue((opts.InterceptorProfiles).ContainsKey("encrypted"));
Assert.AreSame(action, opts.InterceptorProfiles["encrypted"]);
}

[TestMethod]
Expand All @@ -46,7 +46,7 @@ public void AddInterceptorProfile_Is_Case_Insensitive()
var opts = new DashboardOptions();
Action<IContainer> action = _ => { };
opts.AddInterceptorProfile("Encrypted", action);
opts.InterceptorProfiles.Should().ContainKey("encrypted");
Assert.IsTrue((opts.InterceptorProfiles).ContainsKey("encrypted"));
}

[TestMethod]
Expand All @@ -57,45 +57,45 @@ public void AddInterceptorProfile_Overwrites_Existing()
Action<IContainer> second = _ => { };
opts.AddInterceptorProfile("encrypted", first);
opts.AddInterceptorProfile("encrypted", second);
opts.InterceptorProfiles["encrypted"].Should().BeSameAs(second);
Assert.AreSame(second, opts.InterceptorProfiles["encrypted"]);
}

[TestMethod]
public void AddInterceptorProfile_Throws_On_Null_Name()
{
var opts = new DashboardOptions();
Action act = () => opts.AddInterceptorProfile(null, _ => { });
act.Should().Throw<ArgumentException>();
Assert.Throws<ArgumentException>(act);
}

[TestMethod]
public void AddInterceptorProfile_Throws_On_Empty_Name()
{
var opts = new DashboardOptions();
Action act = () => opts.AddInterceptorProfile("", _ => { });
act.Should().Throw<ArgumentException>();
Assert.Throws<ArgumentException>(act);
}

[TestMethod]
public void AddInterceptorProfile_Throws_On_Null_Action()
{
var opts = new DashboardOptions();
Action act = () => opts.AddInterceptorProfile("test", null);
act.Should().Throw<ArgumentNullException>();
Assert.Throws<ArgumentNullException>(act);
}

[TestMethod]
public void EnableCors_Defaults_To_False()
{
var opts = new DashboardOptions();
opts.EnableCors.Should().BeFalse();
Assert.IsFalse(opts.EnableCors);
}

[TestMethod]
public void CorsOrigins_Defaults_To_Empty()
{
var opts = new DashboardOptions();
opts.CorsOrigins.Should().BeEmpty();
Assert.IsFalse((opts.CorsOrigins).Any());
}

[TestMethod]
Expand All @@ -106,15 +106,16 @@ public void CorsOrigins_Can_Be_Set()
EnableCors = true,
CorsOrigins = new[] { "http://localhost:5000" }
};
opts.EnableCors.Should().BeTrue();
opts.CorsOrigins.Should().ContainSingle().Which.Should().Be("http://localhost:5000");
Assert.IsTrue(opts.EnableCors);
Assert.AreEqual(1, (opts.CorsOrigins).Count());
Assert.AreEqual("http://localhost:5000", (opts.CorsOrigins).Single());
}

[TestMethod]
public void AssemblyPaths_Defaults_To_Empty()
{
var opts = new DashboardOptions();
opts.AssemblyPaths.Should().BeEmpty();
Assert.IsFalse((opts.AssemblyPaths).Any());
}

[TestMethod]
Expand All @@ -124,9 +125,9 @@ public void AssemblyPaths_Can_Be_Set()
{
AssemblyPaths = new[] { "/app/plugins", "/opt/dlls" }
};
opts.AssemblyPaths.Should().HaveCount(2);
opts.AssemblyPaths[0].Should().Be("/app/plugins");
opts.AssemblyPaths[1].Should().Be("/opt/dlls");
Assert.AreEqual(2, (opts.AssemblyPaths).Count());
Assert.AreEqual("/app/plugins", opts.AssemblyPaths[0]);
Assert.AreEqual("/opt/dlls", opts.AssemblyPaths[1]);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNetWorkQueue.Dashboard.Api.Configuration;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration
Expand All @@ -11,35 +10,35 @@ public class DashboardQueueOptionsTests
public void QueueName_Can_Be_Set()
{
var opts = new DashboardQueueOptions { QueueName = "MyQueue" };
opts.QueueName.Should().Be("MyQueue");
Assert.AreEqual("MyQueue", opts.QueueName);
}

[TestMethod]
public void InterceptorConfiguration_Defaults_To_Null()
{
var opts = new DashboardQueueOptions();
opts.InterceptorConfiguration.Should().BeNull();
Assert.IsNull(opts.InterceptorConfiguration);
}

[TestMethod]
public void InterceptorProfile_Defaults_To_Null()
{
var opts = new DashboardQueueOptions();
opts.InterceptorProfile.Should().BeNull();
Assert.IsNull(opts.InterceptorProfile);
}

[TestMethod]
public void InterceptorProfile_Can_Be_Set()
{
var opts = new DashboardQueueOptions { InterceptorProfile = "encrypted" };
opts.InterceptorProfile.Should().Be("encrypted");
Assert.AreEqual("encrypted", opts.InterceptorProfile);
}

[TestMethod]
public void Interceptors_Defaults_To_Null()
{
var opts = new DashboardQueueOptions();
opts.Interceptors.Should().BeNull();
Assert.IsNull(opts.Interceptors);
}

[TestMethod]
Expand All @@ -50,7 +49,7 @@ public void Interceptors_Can_Be_Set()
GZip = new GZipInterceptorOptions()
};
var opts = new DashboardQueueOptions { Interceptors = interceptors };
opts.Interceptors.Should().BeSameAs(interceptors);
Assert.AreSame(interceptors, opts.Interceptors);
}
}
}
Loading
Loading