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)); }
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); }