You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've inherited a legacy codebase with some extremely large service registries, and said registries are used in tests.
There is a test registry that removes some specific service registrations as some of the logic shouldn't run in the tests.
There is one test written to assert that the test registry is removing the services as expected (this is where the exception is thrown).
e.g.
class ClassA {}
class ClassB {}
interface IGenericService<T> {}
class ServiceA : IGenericService<ClassA> {}
class ServiceB : IGenericService<ClassB> {}
class AppRegistry : ServiceRegistry
{
// a huge number of nested registries and services here
For<IGenericService<ClassA>>().Use<ServiceA>();
For<IGenericService<ClassB>>().Use<ServiceB>();
// a huge number of nested registries and services here
}
class TestRegistry : ServiceRegistry
{
IncludeRegistry<AppRegistry>();
RemoveAll(x => x.ServiceType == typeof(IGenericService<>);
}
// the "registry" test
void EnsureServicesAreNotRegistered()
{
var container = new Container(x => x.IncludeRegistry<TestRegistry>());
// Exception thrown here
var hasRegistrations = container.Model.HasRegistrationsFor(typeof(IGenericService<>));
Assert.False(hasRegistrations);
}
public IEnumerable<Instance> AllInstances() { return _families.Values.ToArray().SelectMany(x => x.All).ToArray(); }
NullReferenceException is thrown any time the above method is called when a value in _families.Values is null.
The text was updated successfully, but these errors were encountered: