Пример #1
0
        public void Null_Configuration_Throws()
        {
            var activator = new ModelActivator(null);

            activator.Invoking(x => x.CreateInstance(null))
            .Should()
            .ThrowExactly <NullReferenceException>();
        }
Пример #2
0
        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>();
        }
Пример #3
0
        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>();
        }