コード例 #1
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        public async Task GivenNullValue_CallGetVisitingAndLoadAsync_MustThrowExcetpion()
        {
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => ComicHostExtensions.GetVisitingAndLoadAsync <Stream>(null, "-any-"));

            await Assert.ThrowsExceptionAsync <ArgumentException>(() => ComicHostExtensions.GetVisitingAndLoadAsync <Stream>(new NullServiceProvider(), null));

            await Assert.ThrowsExceptionAsync <ArgumentException>(() => ComicHostExtensions.GetVisitingAndLoadAsync <Stream>(new NullServiceProvider(), string.Empty));
        }
コード例 #2
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        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);
        }
コード例 #3
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        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);
        }
コード例 #4
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        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);
        }
コード例 #5
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        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);
        }
コード例 #6
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
        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);
        }
コード例 #7
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
 public void GivenNullValue_CallGetComicEngine_MustThrowException()
 {
     Assert.ThrowsException <ArgumentNullException>(() => ComicHostExtensions.GetComicEngine(null));
 }
コード例 #8
0
ファイル: ComicHostExtensionsTest.cs プロジェクト: Cricle/Anf
 public async Task GivenNullValue_CallSearchAsync_MustThrowException()
 {
     await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => ComicHostExtensions.SearchAsync(null, null, 0, 0));
 }