Skip to content

Commit

Permalink
Updated unit test to assert that the exception thrown is the exact ex…
Browse files Browse the repository at this point in the history
…ception expected.
  • Loading branch information
alexmg committed Jan 26, 2014
1 parent 346d530 commit 5c6a4e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static Type GetInterface(Type implementationType, Type serviceType)
}
catch (InvalidOperationException)
{
var message = string.Format(OpenGenericServiceBinderResources.ImplementorDoesntImplementService, implementationType.FullName, serviceType.FullName);
var message = string.Format(CultureInfo.CurrentCulture, OpenGenericServiceBinderResources.ImplementorDoesntImplementService, implementationType.FullName, serviceType.FullName);
throw new DependencyResolutionException(message);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ImplementorDoesntImplementService" xml:space="preserve">
<value>The type '{0}' does not implement the interface '{1}'</value>
<value>The type '{0}' does not implement the interface '{1}'.</value>
</data>
<data name="ImplementorMustBeOpenGenericTypeDefinition" xml:space="preserve">
<value>The implementation type '{0}' is not an open generic type definition.</value>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Autofac.Features.OpenGenerics;
using NUnit.Framework;
using Autofac.Core;
using System.Collections.Generic;
Expand Down Expand Up @@ -175,12 +176,11 @@ public void WhenAnOpenGenericIsRegisteredAndItProvidesNoImplementationItShouldHa
{
var cb = new ContainerBuilder();
cb.RegisterGeneric(typeof(FG<>)).As(typeof(IG<>));

Assert.Throws<DependencyResolutionException>(() =>
{
cb.Build();
});


var exception = Assert.Throws<DependencyResolutionException>(() => cb.Build());

var message = string.Format(OpenGenericServiceBinderResources.ImplementorDoesntImplementService, typeof(FG<>).FullName, typeof(IG<>).FullName);
Assert.That(exception.Message, Is.EqualTo(message));
}
}
}

0 comments on commit 5c6a4e8

Please sign in to comment.