public void Null_Configuration_Throws() { var activator = new ModelActivator(null); activator.Invoking(x => x.CreateInstance(null)) .Should() .ThrowExactly <NullReferenceException>(); }
public void NoFactory_Throws() { var activator = new ModelActivator(null); var source = new ListConfiguration(typeof(Request), typeof(Item), typeof(Result)) { ModelActivatorConfiguration = new ModelActivatorConfiguration(null, null, null) }; activator.Invoking(x => x.CreateInstance(source)) .Should() .ThrowExactly <ArgumentException>(); }
public void UnableToResolveFactory_Throws() { var serviceProvider = new ServiceCollection().BuildServiceProvider(); var httpContext = new Mock <HttpContext>(); var hca = new Mock <IHttpContextAccessor>(); hca.SetupGet(x => x.HttpContext).Returns(httpContext.Object); httpContext.SetupGet(x => x.RequestServices).Returns(serviceProvider); var activator = new ModelActivator(hca.Object); var source = new ListConfiguration(typeof(Request), typeof(Item), typeof(Result)) { ModelActivatorConfiguration = new ModelActivatorConfiguration(typeof(Request)) }; activator.Invoking(x => x.CreateInstance(source)) .Should() .ThrowExactly <NullReferenceException>(); }