示例#1
0
        public void GivenServiceCollectionWhenAddLazyListShouldInitializeFactory()
        {
            var services = new ServiceCollection();

            services.AddLazyList(typeof(StubLazyLoadResolver <>).Assembly);

            Func <IList <Stub> > action = () => LazyListFactory.CreateList <Stub>(1);

            action.Should().NotThrow();
        }
        public void GivenLazyListFactoryWhenStaticCreateShouldReturnInstance()
        {
            _serviceProviderMock.Setup(x => x.GetService(typeof(ILazyLoadResolver <IEnumerable <Stub> >)))
            .Returns(_lazyLoadResolverMock.Object);
            LazyListFactory.RegisterInstance(_lazyListFactory);
            var list = LazyListFactory.CreateList <Stub>(1);

            list.Should().NotBeNull();
            list.Should().BeOfType <LazyList <Stub> >();
            _serviceProviderMock.VerifyAll();
        }
示例#3
0
        public void GivenServiceCollectionWhenAddLazyListShouldRegisterOpenTypeGenericsAndSpecificTypes()
        {
            var services = new ServiceCollection();

            services.AddLazyList(typeof(StubLazyLoadResolver <>).Assembly);

            var stubs = LazyListFactory.CreateList <Stub>(1);

            stubs.Should().NotBeNull();
            stubs.Should().BeOfType <LazyList <Stub> >();
        }
        public void GivenLazyListFactoryWhenStaticCreateAndNotInitShouldThrow()
        {
            Func <IList <Stub> > action = () => LazyListFactory.CreateList <Stub>(1);

            action.Should().Throw <InvalidOperationException>();
        }