Skip to content

Commit

Permalink
Update GlobalConfigurationExtensionsFacts.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
odinserj committed Sep 24, 2024
1 parent 0646e23 commit 3b7e357
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Hangfire.Autofac.Tests/GlobalConfigurationExtensionsFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,40 @@ public void UseAutofacActivator_CallsUseActivatorCorrectly()

Assert.IsType<AutofacJobActivator>(JobActivator.Current);
}

#if !NET452
[Fact]
public void UseAutofacActivator_WithConfigurationAction_ThrowsAnException_WhenConfigurationIsNull()
{
var lifetimeScope = new Moq.Mock<ILifetimeScope>();

var exception = Assert.Throws<ArgumentNullException>(
() => ((IGlobalConfiguration)null).UseAutofacActivator(lifetimeScope.Object, (_, _) => { }));

Assert.Equal("configuration", exception.ParamName);
}

[Fact]
public void UseAutofacActivator_WithConfigurationAction_ThrowsAnException_WhenLifetimeScopeIsNull()
{
var configuration = new Moq.Mock<IGlobalConfiguration>();

var exception = Assert.Throws<ArgumentNullException>(
() => configuration.Object.UseAutofacActivator(null, (_, _) => { }));

Assert.Equal("lifetimeScope", exception.ParamName);
}

[Fact]
public void UseAutofacActivator_WithConfigurationAction_CallsUseActivatorCorrectly()
{
var configuration = new Moq.Mock<IGlobalConfiguration>();
var lifetimeScope = new Moq.Mock<ILifetimeScope>();

configuration.Object.UseAutofacActivator(lifetimeScope.Object, (_, _) => { });

Assert.IsType<AutofacJobActivator>(JobActivator.Current);
}
#endif
}
}

0 comments on commit 3b7e357

Please sign in to comment.