public void CallGetComicEngine_MustReturnEngineInstance()
        {
            var eng      = new ComicEngine();
            var provider = new ValueServiceProvider
            {
                ServiceMap = new Dictionary <Type, Func <object> >
                {
                    [typeof(ComicEngine)] = () => eng
                }
            };
            var retEng = ComicHostExtensions.GetComicEngine(provider);

            Assert.AreEqual(eng, retEng);
        }
        public async Task GetVisitingAndLoadAsync_MustReturnLoadedVisitor()
        {
            var provider = new ValueServiceProvider
            {
                ServiceMap = new Dictionary <Type, Func <object> >
                {
                    [typeof(IComicVisiting <Stream>)] = () => ComicVisitingHelper.CreateResrouceVisitor()
                }
            };
            var visitor = await ComicHostExtensions.GetVisitingAndLoadAsync <Stream>(provider, "http://localhost:8887");

            Assert.IsNotNull(visitor);
            Assert.IsNotNull(visitor.Entity);
        }
        public async Task GetVisitingAndLoadAsync_FailToLoad_MustReturnNull()
        {
            var provider = new ValueServiceProvider
            {
                ServiceMap = new Dictionary <Type, Func <object> >
                {
                    [typeof(IComicVisiting <Stream>)] = () => new NullComicVisiting <Stream> {
                        LoadSucceed = false
                    }
                }
            };
            var visitor = await ComicHostExtensions.GetVisitingAndLoadAsync <Stream>(provider, "http://localhost:8889");

            Assert.IsNull(visitor);
        }
        public void CallGetServiceScope_MustReturnScopeInstance()
        {
            var scope    = new NullServiceScope();
            var provider = new ValueServiceProvider
            {
                ServiceMap = new Dictionary <Type, Func <object> >
                {
                    [typeof(IServiceScopeFactory)] = () => new ValueServiceScopeFactory {
                        ScopeFactory = () => scope
                    }
                }
            };

            var retScope = ComicHostExtensions.GetServiceScope(provider);

            Assert.AreEqual(scope, retScope);
        }
        public async Task SearchAsync_MustReturnSearchResult()
        {
            var provider = new ValueServiceProvider
            {
                ServiceMap = new Dictionary <Type, Func <object> >
                {
                }
            };
            var provfc = new ValueServiceScopeFactory {
                ScopeFactory = () => new ValueServiceScope {
                    ServiceProvider = provider
                }
            };
            var eng = new SearchEngine(provfc);

            provider.ServiceMap[typeof(SearchEngine)] = () => eng;
            provider.ServiceMap
            [typeof(IServiceScopeFactory)] = () => provfc;
            var res = await ComicHostExtensions.SearchAsync(provider, null, 5, 10);

            Assert.IsNotNull(res);
        }