public void GetInstance_returns_service_instance_from_provider([Frozen] IServiceProvider serviceProvider, [Frozen] Type serviceType, TestService serviceInstance, DependencyInjectionInstanceProvider sut, InstanceContext instanceContext) { Mock.Get(serviceProvider).Setup(p => p.GetService(serviceType)).Returns(serviceInstance); var result = sut.GetInstance(instanceContext); Assert.That(result, Is.SameAs(serviceInstance)); }
public void GetInstance_throws_if_service_cannot_be_resolved([Frozen] IServiceProvider serviceProvider, [Frozen] Type serviceType, TestService serviceInstance, DependencyInjectionInstanceProvider sut, InstanceContext instanceContext, Exception exception) { Mock.Get(serviceProvider).Setup(p => p.GetService(serviceType)).Throws(exception); Assert.Throws <Exception>(() => sut.GetInstance(instanceContext)); }
public void GetInstance_throws_if_instanceContext_is_null(DependencyInjectionInstanceProvider sut) { Assert.Throws <ArgumentNullException>(() => sut.GetInstance(null)); }