public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper = MockRepository.GenerateMock <IIdMapper>();
     _idMapper
     .Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = IdResult.IdMapped(Guid.NewGuid()).AsCompletedTask())
     .Return(null);
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped("name").AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _autoRouteCollection = new AutoRouteCollection(true)
                            .Assemblies(Assembly.GetExecutingAssembly())
                            .ClassFilters(_classFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper);
 }
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper = MockRepository.GenerateMock <IIdMapper>();
     _idMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.NewGuid()).AsCompletedTask());
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped("name").AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _authenticationProvider = MockRepository.GenerateMock <IAuthenticationProvider>();
     _authenticationProvider
     .Stub(arg => arg.AuthenticateAsync(Arg <HttpRequestBase> .Is.Anything, Arg <HttpResponseBase> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything))
     .Return(AuthenticationResult.AuthenticationSucceeded.AsCompletedTask());
     _authenticationStrategy = MockRepository.GenerateMock <IAuthenticationStrategy>();
     _authenticationStrategy.Stub(arg => arg.MustAuthenticateAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(true.AsCompletedTask());
     _autoRouteCollection = new AutoRouteCollection()
                            .Assemblies(Assembly.GetExecutingAssembly())
                            .ClassFilters(_classFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
                            .Authenticate(_authenticationProvider, _authenticationStrategy);
     _routes = _autoRouteCollection.GenerateRouteCollectionAsync().Result.ToArray();
 }
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper = MockRepository.GenerateMock <IIdMapper>();
     _idMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.NewGuid()).AsCompletedTask());
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped("name").AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _responseMapper = MockRepository.GenerateMock <IResponseMapper>();
     _responseMapper
     .Stub(arg => arg.MapAsync(Arg <Func <IContainer> > .Is.Anything, Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything))
     .Return(Task.Factory.Empty());
     _restrictionMapper1 = MockRepository.GenerateMock <IRestrictionMapper>();
     _restrictionMapper1
     .Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything, Arg <IContainer> .Is.Anything))
     .WhenCalled(arg => ((Route.Routing.Route)arg.Arguments.Skip(2).First()).RestrictByMethods("GET").AsCompletedTask())
     .Return(Task.Factory.Empty());
     _restrictionMapper2 = MockRepository.GenerateMock <IRestrictionMapper>();
     _restrictionMapper2
     .Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything, Arg <IContainer> .Is.Anything))
     .WhenCalled(arg => ((Route.Routing.Route)arg.Arguments.Skip(2).First()).RestrictByMethods("POST").AsCompletedTask())
     .Return(Task.Factory.Empty());
     _autoRouteCollection = new AutoRouteCollection()
                            .Assemblies(Assembly.GetExecutingAssembly())
                            .ClassFilters(_classFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
                            .ResponseMapper(_responseMapper)
                            .RestrictionMappers(_restrictionMapper1, _restrictionMapper2);
 }
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper1 = MockRepository.GenerateMock <IIdMapper>();
     _idMapper1.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.Parse("1dffe3ee-1ade-4aa2-835a-9cb91b7e31c4")).AsCompletedTask());
     _idMapper2 = MockRepository.GenerateMock <IIdMapper>();
     _idMapper2.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.Parse("493e725c-cbc1-4ea4-b6d1-350018d4542d")).AsCompletedTask());
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped("name").AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _responseMapper = MockRepository.GenerateMock <IResponseMapper>();
     _responseMapper
     .Stub(arg => arg.MapAsync(Arg <Func <IContainer> > .Is.Anything, Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything))
     .Return(Task.Factory.Empty());
     _autoRouteCollection = new AutoRouteCollection()
                            .Assemblies(Assembly.GetExecutingAssembly())
                            .ClassFilters(_classFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper1)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
                            .ResponseMapper(_responseMapper);
     _routes = _autoRouteCollection.GenerateRouteCollectionAsync().Result.ToArray();
 }
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper = MockRepository.GenerateMock <IIdMapper>();
     _idMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.NewGuid()).AsCompletedTask());
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped(Guid.NewGuid().ToString()).AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _responseMapper = MockRepository.GenerateMock <IResponseMapper>();
     _responseMapper
     .Stub(arg => arg.MapAsync(Arg <Func <IContainer> > .Is.Anything, Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything))
     .Return(Task.Factory.Empty());
     _httpRuntime         = MockRepository.GenerateMock <IHttpRuntime>();
     _autoRouteCollection = new AutoRouteCollection()
                            .Assemblies(typeof(Endpoint).Assembly)
                            .ClassFilters(_classFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
                            .RestrictUsingAttributes <UrlRelativePathAttribute>()
                            .RestrictRelativePathsToRelativeClassNamespaceAndClassName("")
                            .ResponseMapper(_responseMapper)
                            .RestrictionContainer(new DefaultRestrictionContainer(_httpRuntime));
     _routes = _autoRouteCollection.GenerateRouteCollectionAsync().Result.ToArray();
 }
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock <IClassFilter>();
     _classFilter
     .Stub(arg => arg.MatchesAsync(Arg <Type> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = ((Type)arg.Arguments.First() == typeof(Endpoint)).AsCompletedTask())
     .Return(false.AsCompletedTask());
     _methodFilter = MockRepository.GenerateMock <IMethodFilter>();
     _methodFilter
     .Stub(arg => arg.MatchesAsync(Arg <MethodInfo> .Is.Anything))
     .WhenCalled(arg => arg.ReturnValue = (((MethodInfo)arg.Arguments.First()).Name == "IncludedMethod").AsCompletedTask())
     .Return(false.AsCompletedTask());
     _idMapper = MockRepository.GenerateMock <IIdMapper>();
     _idMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(IdResult.IdMapped(Guid.NewGuid()).AsCompletedTask());
     _nameMapper = MockRepository.GenerateMock <INameMapper>();
     _nameMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(NameResult.NameMapped("name").AsCompletedTask());
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock <IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.MapAsync(Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative").AsCompletedTask());
     _responseMapper = MockRepository.GenerateMock <IResponseMapper>();
     _responseMapper
     .Stub(arg => arg.MapAsync(Arg <Func <IContainer> > .Is.Anything, Arg <Type> .Is.Anything, Arg <MethodInfo> .Is.Anything, Arg <Route.Routing.Route> .Is.Anything))
     .Return(Task.Factory.Empty());
     _autoRouteCollection = new AutoRouteCollection()
                            .Assemblies(Assembly.GetExecutingAssembly())
                            .ClassFilters(_classFilter)
                            .MethodFilters(_methodFilter)
                            .NameMappers(_nameMapper)
                            .IdMappers(_idMapper)
                            .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
                            .ResponseMapper(_responseMapper);
     _routes = _autoRouteCollection.GenerateRouteCollectionAsync().Result.ToArray();
 }
Esempio n. 7
0
 public void SetUp()
 {
     _id     = Guid.NewGuid();
     _result = IdResult.IdMapped(_id);
 }