Commit 3388d327 authored by Adrian Ramcharitar's avatar Adrian Ramcharitar

Changed Fact tests to Theory

parent 2ca2ce54
Pipeline #57261484 passed with stages
in 7 minutes and 31 seconds
......@@ -11,6 +11,7 @@ using Foci.Orbital.Agent.Services.Interface;
using Foci.Orbital.Agent.Services.Interfaces;
using NSubstitute;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
......@@ -25,72 +26,36 @@ namespace Foci.Orbital.Agent.Tests.Services
private readonly Faker faker = new Faker();
/// <summary>
/// Test passing null configuration service to ServiceDefinitionService
/// Test passing null ConfigurationService, BusService, ServiceDefinitionRepository and OperationsHandler to DefinitionService
/// </summary>
[Fact]
[Trait("Category", "Failure")]
public void DefinitionServiceNullConfiguration()
[Theory]
[ClassData(typeof(ServiceDefinitionServiceData))]
internal void DefinitionServiceNull(IConfigurationService configuration,
IBusService busService,
IServiceDefinitionRepository serviceDefinitionRepository,
IOperationsHandler operationsHandler)
{
#region Substitutions
IBusService subBusService = Substitute.For<IBusService>();
IServiceDefinitionRepository serviceDefinitionRepository = Substitute.For<IServiceDefinitionRepository>();
IOperationsHandler operationsHandler = Substitute.For<IOperationsHandler>();
#endregion
Assert.Throws<ArgumentNullException>(() => new ServiceDefinitionService(null, subBusService, serviceDefinitionRepository, operationsHandler));
Assert.Throws<ArgumentNullException>(() => new ServiceDefinitionService(configuration, busService, serviceDefinitionRepository, operationsHandler));
}
/// <summary>
/// Test passing null bus service to DefinitionService
/// </summary>
[Fact]
[Trait("Category", "Failure")]
public void DefinitionServiceNullBusService()
{
#region Substitutions
IConfigurationService subConfiguration = Substitute.For<IConfigurationService>();
IBusService subBusService = Substitute.For<IBusService>();
IServiceDefinitionRepository serviceDefinitionRepository = Substitute.For<IServiceDefinitionRepository>();
IOperationsHandler operationsHandler = Substitute.For<IOperationsHandler>();
#endregion
Assert.Throws<ArgumentNullException>(() => new ServiceDefinitionService(subConfiguration, null, serviceDefinitionRepository, operationsHandler));
}
/// <summary>
/// Test passing null file repository to DefinitionService
/// </summary>
[Fact]
[Trait("Category", "Failure")]
public void DefinitionServiceNullDefinitionRepository()
public class ServiceDefinitionServiceData : IEnumerable<object[]>
{
#region Substitutions
IConfigurationService subConfiguration = Substitute.For<IConfigurationService>();
IBusService subBusService = Substitute.For<IBusService>();
IOperationsHandler operationsHandler = Substitute.For<IOperationsHandler>();
#endregion
Assert.Throws<ArgumentNullException>(() => new ServiceDefinitionService(subConfiguration, subBusService, null, operationsHandler));
}
/// <summary>
/// Test passing null operations handler to DefinitionService
/// </summary>
[Fact]
[Trait("Category", "Failure")]
public void DefinitionServiceNullOperationsHandler()
{
#region Substitutions
IConfigurationService subConfiguration = Substitute.For<IConfigurationService>();
IBusService subBusService = Substitute.For<IBusService>();
IServiceDefinitionRepository serviceDefinitionRepository = Substitute.For<IServiceDefinitionRepository>();
#endregion
public IEnumerator<object[]> GetEnumerator()
{
IConfigurationService subConfiguration = Substitute.For<IConfigurationService>();
IBusService subBusService = Substitute.For<IBusService>();
IServiceDefinitionRepository serviceDefinitionRepository = Substitute.For<IServiceDefinitionRepository>();
IOperationsHandler operationsHandler = Substitute.For<IOperationsHandler>();
yield return new object[] { subConfiguration, subBusService, serviceDefinitionRepository, null };
yield return new object[] { subConfiguration, subBusService, null, operationsHandler };
yield return new object[] { subConfiguration, null, serviceDefinitionRepository, operationsHandler };
yield return new object[] { null, subBusService, serviceDefinitionRepository, operationsHandler };
}
Assert.Throws<ArgumentNullException>(() => new ServiceDefinitionService(subConfiguration, subBusService, serviceDefinitionRepository, null));
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
/// <summary>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment