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
Expand Up @@ -80,7 +80,7 @@ public virtual ServiceImplementationData GetServiceImplementationData(string val
}
}

if (serviceRegistration == null)
if (serviceRegistration == null || serviceRegistration == default)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, AutofacHostFactoryResources.ServiceNotRegistered, value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public void DetectsUnknownImplementationTypes()
});
}

[Fact]
public void DetectsUnknownServiceTypes()
{
var builder = new ContainerBuilder();
// No service registered at all.
TestWithHostedContainer(builder.Build(), () =>
{
var factory = new T();
Assert.Throws<InvalidOperationException>(() => factory.CreateServiceHost("service", _dummyEndpoints));
});
}

[Fact]
public void ExecutesHostConfigurationActionWhenSet()
{
Expand Down Expand Up @@ -169,4 +181,4 @@ private static void TestWithHostedContainer(IContainer container, Action test)
}
}
}
}
}