コード例 #1
0
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock<IClassFilter>();
     _classFilter
         .Stub(arg => arg.Matches(Arg<Type>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = (Type)arg.Arguments.First() == typeof(Endpoint))
         .Return(false);
     _idMapper = MockRepository.GenerateMock<IIdMapper>();
     _idMapper
         .Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = IdResult.IdMapped(Guid.NewGuid()))
         .Return(null);
     _nameMapper = MockRepository.GenerateMock<INameMapper>();
     _nameMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(NameResult.NameMapped("name"));
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock<IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative"));
     _autoRouteCollection = new AutoRouteCollection(true)
         .Assemblies(Assembly.GetExecutingAssembly())
         .ClassFilters(_classFilter)
         .NameMappers(_nameMapper)
         .IdMappers(_idMapper)
         .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper);
 }
コード例 #2
0
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock<IClassFilter>();
     _classFilter
         .Stub(arg => arg.Matches(Arg<Type>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = (Type)arg.Arguments.First() == typeof(Endpoint))
         .Return(false);
     _idMapper = MockRepository.GenerateMock<IIdMapper>();
     _idMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(IdResult.IdMapped(Guid.NewGuid()));
     _nameMapper = MockRepository.GenerateMock<INameMapper>();
     _nameMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(NameResult.NameMapped("name"));
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock<IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative"));
     _responseMapper = MockRepository.GenerateMock<IResponseMapper>();
     _restrictionMapper1 = MockRepository.GenerateMock<IRestrictionMapper>();
     _restrictionMapper1
         .Stub(arg => arg.Map(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"));
     _restrictionMapper2 = MockRepository.GenerateMock<IRestrictionMapper>();
     _restrictionMapper2
         .Stub(arg => arg.Map(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"));
     _autoRouteCollection = new AutoRouteCollection()
         .Assemblies(Assembly.GetExecutingAssembly())
         .ClassFilters(_classFilter)
         .NameMappers(_nameMapper)
         .IdMappers(_idMapper)
         .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
         .ResponseMapper(_responseMapper)
         .RestrictionMappers(_restrictionMapper1, _restrictionMapper2);
 }
コード例 #3
0
 public void SetUp()
 {
     _classFilter = MockRepository.GenerateMock<IClassFilter>();
     _classFilter
         .Stub(arg => arg.Matches(Arg<Type>.Is.Anything))
         .WhenCalled(arg => arg.ReturnValue = (Type)arg.Arguments.First() == typeof(Endpoint))
         .Return(false);
     _idMapper1 = MockRepository.GenerateMock<IIdMapper>();
     _idMapper1.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(IdResult.IdMapped(Guid.Parse("1dffe3ee-1ade-4aa2-835a-9cb91b7e31c4")));
     _idMapper2 = MockRepository.GenerateMock<IIdMapper>();
     _idMapper2.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(IdResult.IdMapped(Guid.Parse("493e725c-cbc1-4ea4-b6d1-350018d4542d")));
     _nameMapper = MockRepository.GenerateMock<INameMapper>();
     _nameMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(NameResult.NameMapped("name"));
     _resolvedRelativeUrlMapper = MockRepository.GenerateMock<IResolvedRelativeUrlMapper>();
     _resolvedRelativeUrlMapper.Stub(arg => arg.Map(Arg<Type>.Is.Anything, Arg<MethodInfo>.Is.Anything)).Return(ResolvedRelativeUrlResult.ResolvedRelativeUrlMapped("relative"));
     _responseMapper = MockRepository.GenerateMock<IResponseMapper>();
     _autoRouteCollection = new AutoRouteCollection()
         .Assemblies(Assembly.GetExecutingAssembly())
         .ClassFilters(_classFilter)
         .NameMappers(_nameMapper)
         .IdMappers(_idMapper1)
         .ResolvedRelativeUrlMappers(_resolvedRelativeUrlMapper)
         .ResponseMapper(_responseMapper);
     _routes = _autoRouteCollection.GenerateRouteCollection().ToArray();
 }