Changeset 429
- Timestamp:
- 02/09/10 00:27:11 (6 months ago)
- Location:
- trunk/src/core
- Files:
-
- 4 removed
- 80 modified
- 34 copied
-
OpenRasta (modified) (1 prop)
-
OpenRasta.Client (modified) (1 prop)
-
OpenRasta.Net30 (modified) (1 prop)
-
OpenRasta.Net35 (modified) (1 prop)
-
OpenRasta.Testing (modified) (1 prop)
-
OpenRasta.Tests.Integration (modified) (1 prop)
-
OpenRasta.Tests.Integration/Binding/CustomSurrogates.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta.Tests.Integration/Binding/CustomSurrogates.cs)
-
OpenRasta.Tests.Integration/OpenRasta.Tests.Integration.csproj (modified) (2 diffs)
-
OpenRasta.Tests.Integration/Security/DigestAuthentication_Specification.cs (modified) (3 diffs)
-
OpenRasta.Tests.Integration/Settings.StyleCop (copied) (copied from branches/2.0.3000/src/core/OpenRasta.Tests.Integration/Settings.StyleCop)
-
OpenRasta.Tests.Unit (modified) (1 prop)
-
OpenRasta.Tests.Unit/Binding/DefaultBinderLocator_Specification.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/Binding/KeyedValuesBinder_Specification.cs (modified) (2 diffs)
-
OpenRasta.Tests.Unit/Codecs/ApplicationXWwwUrlformEncodedCodec_Specification.cs (modified) (2 diffs)
-
OpenRasta.Tests.Unit/Codecs/CodecMatch_Specification.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/Codecs/CodecRepository_Specification.cs (modified) (3 diffs)
-
OpenRasta.Tests.Unit/Codecs/MultipartFormDataCodec_Specification.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/Codecs/media_type_reader_context.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/Configuration/LegacyManualConfiguration_Specification.cs (modified) (3 diffs)
-
OpenRasta.Tests.Unit/Configuration/MetaModelHandler_Specification.cs (modified) (5 diffs)
-
OpenRasta.Tests.Unit/Configuration/MetaModel_Specification.cs (modified) (2 diffs)
-
OpenRasta.Tests.Unit/Fakes/Customer.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/OpenRasta.Tests.Unit.csproj (modified) (1 diff)
-
OpenRasta.Tests.Unit/OperationModel/CodecSelectors/RequestCodecSelector_Specification.cs (modified) (4 diffs)
-
OpenRasta.Tests.Unit/Settings.StyleCop (modified) (3 diffs)
-
OpenRasta.Tests.Unit/TypeSystem/Instances_Specification.cs (modified) (22 diffs)
-
OpenRasta.Tests.Unit/TypeSystem/Members_Specification.cs (modified) (22 diffs)
-
OpenRasta.Tests.Unit/TypeSystem/Surrogate2_Specification.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta.Tests.Unit/TypeSystem/Surrogate2_Specification.cs)
-
OpenRasta.Tests.Unit/TypeSystem/Surrogates_Specification.cs (modified) (9 diffs)
-
OpenRasta.Tests.Unit/Web/Handlers/HandlerRepository_Specification.cs (modified) (6 diffs)
-
OpenRasta.Tests.Unit/Web/Markup/SelectElement_Specification.cs (modified) (2 diffs)
-
OpenRasta.Tests.Unit/Web/Pipeline/Contributors/ResponseEntityWriter_Specification.cs (modified) (1 diff)
-
OpenRasta.Tests.Unit/Web/TemplatedUriResolver_Specification.cs (modified) (11 diffs)
-
OpenRasta.Tests.Unit/openrasta_context.cs (modified) (4 diffs)
-
OpenRasta/Binding/BinderAttribute.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/Binding/BinderAttribute.cs)
-
OpenRasta/Binding/BinderBaseAttribute.cs (modified) (1 diff)
-
OpenRasta/Binding/BindingResult.cs (modified) (3 diffs)
-
OpenRasta/Binding/ChangeSetBinder.cs (modified) (1 diff)
-
OpenRasta/Binding/DefaultObjectBinderLocator.cs (modified) (2 diffs)
-
OpenRasta/Binding/IObjectBinder.cs (modified) (1 diff)
-
OpenRasta/Binding/IObjectBinderLocator.cs (modified) (1 diff)
-
OpenRasta/Binding/KeyedValues.cs (modified) (1 diff)
-
OpenRasta/Binding/KeyedValuesBinder.cs (modified) (7 diffs)
-
OpenRasta/Binding/KeyedValuesBinderAttribute.cs (modified) (1 diff)
-
OpenRasta/Binding/KeyedValues`1.cs (modified) (2 diffs)
-
OpenRasta/Binding/ValueConverter.cs (modified) (1 diff)
-
OpenRasta/Codecs/CodecRepository.cs (modified) (3 diffs)
-
OpenRasta/Configuration/DefaultDependencyRegistrar.cs (modified) (9 diffs)
-
OpenRasta/Data/ChangeSet`1.cs (modified) (4 diffs)
-
OpenRasta/IO/IFile.cs (modified) (1 diff)
-
OpenRasta/OpenRasta.csproj (modified) (6 diffs)
-
OpenRasta/OperationModel/CodecSelectors/RequestCodecSelector.cs (modified) (1 diff)
-
OpenRasta/OperationModel/MethodBased/TypeExclusionMethodFilter.cs (modified) (2 diffs)
-
OpenRasta/Pipeline/Contributors/OperationInterceptorContributor.cs (modified) (2 diffs)
-
OpenRasta/Security/RequiresAuthenticationAttribute.cs (modified) (6 diffs)
-
OpenRasta/TypeSystem/DebuggerStrings.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/DebuggerStrings.cs)
-
OpenRasta/TypeSystem/IAttributeProvider.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/IMember.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/IMemberBuilder.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/IMethod.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/IProperty.cs (modified) (2 diffs)
-
OpenRasta/TypeSystem/IPropertyBuilder.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/ISurrogateFactory.cs (deleted)
-
OpenRasta/TypeSystem/ISurrogateProvider.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/ISurrogateProvider.cs)
-
OpenRasta/TypeSystem/IType.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/ITypeBuilder.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/ITypeSystem.cs (modified) (1 diff)
-
OpenRasta/TypeSystem/MemberBuilder.cs (modified) (4 diffs)
-
OpenRasta/TypeSystem/MemberExtensions.cs (modified) (2 diffs)
-
OpenRasta/TypeSystem/ParameterInstance.cs (deleted)
-
OpenRasta/TypeSystem/PropertyBuilder.cs (modified) (4 diffs)
-
OpenRasta/TypeSystem/PropertyExtensions.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/PropertyExtensions.cs) (1 diff)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedMember.cs (modified) (8 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedMethod.cs (modified) (2 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedParameter.cs (modified) (2 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedProperty.cs (modified) (5 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedType.cs (modified) (6 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionBasedTypeSystem.cs (modified) (2 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/ReflectionExtensions.cs (modified) (16 diffs)
-
OpenRasta/TypeSystem/ReflectionBased/Surrogates (deleted)
-
OpenRasta/TypeSystem/ReflectionBased/TypeSystems.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/ReflectionBased/TypeSystems.cs) (2 diffs)
-
OpenRasta/TypeSystem/ReflectionParameter.cs (deleted)
-
OpenRasta/TypeSystem/Surrogated (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated)
-
OpenRasta/TypeSystem/Surrogated/AlienMember.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/AlienMember.cs)
-
OpenRasta/TypeSystem/Surrogated/AlienOwnedProperty.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/AlienOwnedProperty.cs)
-
OpenRasta/TypeSystem/Surrogated/AlienPropertyBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/AlienPropertyBuilder.cs)
-
OpenRasta/TypeSystem/Surrogated/AlienType.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/AlienType.cs)
-
OpenRasta/TypeSystem/Surrogated/IHasWrappedMember.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/IHasWrappedMember.cs)
-
OpenRasta/TypeSystem/Surrogated/IKeepSurrogateInstances.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/IKeepSurrogateInstances.cs)
-
OpenRasta/TypeSystem/Surrogated/MemberWithSurrogates.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/MemberWithSurrogates.cs)
-
OpenRasta/TypeSystem/Surrogated/PropertyWithSurrogates.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/PropertyWithSurrogates.cs)
-
OpenRasta/TypeSystem/Surrogated/PropertyWithSurrogatesBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/PropertyWithSurrogatesBuilder.cs)
-
OpenRasta/TypeSystem/Surrogated/SurrogateBuilderProvider.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/SurrogateBuilderProvider.cs)
-
OpenRasta/TypeSystem/Surrogated/TypeWithSurrogates.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/TypeWithSurrogates.cs)
-
OpenRasta/TypeSystem/Surrogated/TypeWithSurrogatesBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/TypeWithSurrogatesBuilder.cs)
-
OpenRasta/TypeSystem/Surrogated/WrappedMember.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/WrappedMember.cs)
-
OpenRasta/TypeSystem/Surrogated/WrappedProperty.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogated/WrappedProperty.cs)
-
OpenRasta/TypeSystem/Surrogates (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates)
-
OpenRasta/TypeSystem/Surrogates/ISurrogate.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/ISurrogate.cs)
-
OpenRasta/TypeSystem/Surrogates/ISurrogateBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/ISurrogateBuilder.cs)
-
OpenRasta/TypeSystem/Surrogates/Static (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static)
-
OpenRasta/TypeSystem/Surrogates/Static/AbstractStaticSurrogate.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/AbstractStaticSurrogate.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/AbstractStaticSurrogateBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/AbstractStaticSurrogateBuilder.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/CollectionIndexerSurrogate.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/CollectionIndexerSurrogate.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/CollectionSurrogateBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/CollectionSurrogateBuilder.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/DateTimeSurrogate.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/DateTimeSurrogate.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/ListIndexerSurrogate.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/ListIndexerSurrogate.cs)
-
OpenRasta/TypeSystem/Surrogates/Static/ListIndexerSurrogateBuilder.cs (copied) (copied from branches/2.0.3000/src/core/OpenRasta/TypeSystem/Surrogates/Static/ListIndexerSurrogateBuilder.cs)
-
OpenRasta/TypeSystem/TypeBuilder.cs (modified) (10 diffs)
-
OpenRasta/TypeSystem/TypeExtensions.cs (modified) (1 diff)
-
OpenRasta/Web/IHttpEntity.cs (modified) (1 diff)
-
OpenRasta/Web/Markup/Attributes/Annotations/BooleanAttribute.cs (modified) (1 diff)
-
OpenRasta/Web/Markup/Attributes/Nodes/XhtmlAttributeNode.cs (modified) (8 diffs)
-
OpenRasta/Web/Markup/Elements/GenericElement.cs (modified) (1 diff)
-
OpenRasta/Web/Markup/Modules/FormsModule.cs (modified) (1 diff)
-
OpenRasta/Web/TemplatedUriResolver.cs (modified) (7 diffs)
-
core.4.5.resharper (modified) (6 diffs)
-
core.sln (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/OpenRasta
- Property svn:mergeinfo changed
/branches/2.0.3000/src/core/OpenRasta (added) merged: 423-425
- Property svn:mergeinfo changed
-
trunk/src/core/OpenRasta.Client
- Property svn:mergeinfo changed (with no actual effect on merging)
-
trunk/src/core/OpenRasta.Net30
- Property svn:mergeinfo changed (with no actual effect on merging)
-
trunk/src/core/OpenRasta.Net35
- Property svn:mergeinfo changed
/branches/2.0.3000/src/core/OpenRasta.Net35 (added) merged: 425
- Property svn:mergeinfo changed
-
trunk/src/core/OpenRasta.Testing
- Property svn:mergeinfo changed (with no actual effect on merging)
-
trunk/src/core/OpenRasta.Tests.Integration
- Property svn:mergeinfo changed
/branches/2.0.3000/src/core/OpenRasta.Tests.Integration (added) merged: 423,425
- Property svn:mergeinfo changed
-
trunk/src/core/OpenRasta.Tests.Integration/OpenRasta.Tests.Integration.csproj
r421 r429 63 63 <Link>Properties\CommonInfo.cs</Link> 64 64 </Compile> 65 <Compile Include="Binding\CustomSurrogates.cs" /> 65 66 <Compile Include="Regressions\92.cs" /> 66 67 <Compile Include="Codecs\HtmlForm_Specification.cs" /> … … 90 91 </ProjectReference> 91 92 </ItemGroup> 92 <ItemGroup>93 <Folder Include="Binding\" />94 </ItemGroup>95 93 <Import Project="..\..\..\build\defaults.targets" /> 96 94 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/src/core/OpenRasta.Tests.Integration/Security/DigestAuthentication_Specification.cs
r420 r429 12 12 namespace DigestAuthentication_Specification 13 13 { 14 public class when_using_the_correct_credentials : server_context14 public class when_using_the_correct_credentials : context.http_digest_context 15 15 { 16 16 public when_using_the_correct_credentials() … … 40 40 41 41 [Test] 42 public void an_unprotected_resource_returns_200_even_with_invalid_credentials()43 {44 given_client_credentials("username", "wrongpassword");45 given_request("GET", "/unprotected");46 47 when_reading_response_as_a_string(Encoding.ASCII);48 49 TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);50 }51 52 [Test]53 42 public void the_user_authentication_is_successfull_on_URIs_with_encoded_characters() 54 43 { … … 70 59 } 71 60 } 61 public class when_using_incorrect_credentials : context.http_digest_context 62 { 63 [Test] 64 public void a_request_for_a_protected_resource_fails_with_401_response() 65 { 66 given_client_credentials("username", "wrongpassword"); 67 given_request("GET", "/home"); 72 68 69 when_reading_response(); 70 71 TheResponse.StatusCode.ShouldBe(HttpStatusCode.Unauthorized); 72 73 when_reading_response(); 74 75 TheResponse.StatusCode.ShouldBe(HttpStatusCode.Unauthorized); 76 } 77 [Test] 78 public void an_unprotected_resource_returns_200_even_with_invalid_credentials() 79 { 80 given_client_credentials("username", "wrongpassword"); 81 given_request("GET", "/unprotected"); 82 83 when_reading_response_as_a_string(Encoding.ASCII); 84 85 TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK); 86 } 87 88 } 89 namespace context 90 { 91 public class http_digest_context : server_context 92 { 93 94 public http_digest_context() 95 { 96 ConfigureServer(() => 97 { 98 DependencyManager.GetService<IDependencyResolver>() 99 .AddDependency<IAuthenticationProvider, FakeAuthProvider>(); 100 101 ResourceSpace.Has.ResourcesOfType<Customer>() 102 .AtUri("/{somewhere}") 103 .AndAt("/unprotected").Named("unprotected") 104 .HandledBy<ProtectedCustomerHandler>(); 105 }); 106 } 107 } 108 } 73 109 public class FakeAuthProvider : IAuthenticationProvider 74 110 { 75 public Credentials GetByUsername(string p)111 public Credentials GetByUsername(string username) 76 112 { 77 return new Credentials { Username = p, Password = "password" };113 return new Credentials { Username = username, Password = "password" }; 78 114 } 79 115 } 80 116 81 117 public class ProtectedCustomerHandler 82 118 { -
trunk/src/core/OpenRasta.Tests.Unit
- Property svn:mergeinfo changed
/branches/2.0.3000/src/core/OpenRasta.Tests.Unit (added) merged: 423,425
- Property svn:mergeinfo changed
-
trunk/src/core/OpenRasta.Tests.Unit/Binding/DefaultBinderLocator_Specification.cs
r314 r429 18 18 public void the_binder_is_created_correctly() 19 19 { 20 var type = new ReflectionBasedTypeSystem().FromClr(typeof(ClassWithStaticBinder));20 var type = TypeSystems.Default.FromClr(typeof(ClassWithStaticBinder)); 21 21 var binderLocator = new DefaultObjectBinderLocator(); 22 22 -
trunk/src/core/OpenRasta.Tests.Unit/Binding/KeyedValuesBinder_Specification.cs
r414 r429 123 123 } 124 124 [Test] 125 public void multiple_values_with_the_same_name_for_an_icollection_appends_to_the_collection() 126 { 127 var binder = new KeyedValuesBinder(TypeOf<Customer>(), "firstname"); 128 ValueConverter<string> valueConverter = (str, type) => BindingResult.Success(type.CreateInstanceFrom(str)); 129 binder.SetProperty("Attributes", new[] { "blue eyes" }, valueConverter) 130 .ShouldBeTrue(); 131 binder.SetProperty("Attributes", new[] { "green eyes" }, valueConverter) 132 .ShouldBeTrue(); 133 134 var customer = binder.BuildObject().Instance as Customer; 135 customer.Attributes.Count().ShouldBe(2); 136 customer.Attributes.First().ShouldBe("blue eyes"); 137 customer.Attributes.Skip(1).First().ShouldBe("green eyes"); 138 } 139 [Test] 125 140 public void can_build_nested_dictionaries() 126 141 { … … 137 152 protected IType TypeOf<T>() 138 153 { 139 return new ReflectionBasedTypeSystem().FromClr(typeof(T));154 return TypeSystems.Default.FromClr(typeof(T)); 140 155 } 141 156 } -
trunk/src/core/OpenRasta.Tests.Unit/Codecs/ApplicationXWwwUrlformEncodedCodec_Specification.cs
r369 r429 161 161 .ShouldBe("John"); 162 162 customer.LastName 163 .ShouldBe("Doe");163 .ShouldBe("Doe"); 164 164 165 165 customer.DateOfBirth.Day 166 166 .ShouldBe(10); 167 } 168 [Test] 169 public void indexers_are_supported_when_encoded() 170 { 171 given_context(); 172 given_request_stream("Customer.Attributes%3A1=blue&Customer.Attributes%3A2=red"); 173 174 when_decoding<Customer>(); 175 176 then_decoding_result<Customer>() 177 .Attributes.Count().ShouldBe(2); 167 178 } 168 179 … … 183 194 public string FirstName { get; set; } 184 195 public string LastName { get; set; } 196 public IEnumerable<string> Attributes { get; set; } 185 197 public DateTime DateOfBirth { get; set; } 186 198 public Address Address { get; set; } -
trunk/src/core/OpenRasta.Tests.Unit/Codecs/CodecMatch_Specification.cs
r314 r429 69 69 new CodecRegistration( 70 70 typeof (string), 71 new ReflectionBasedTypeSystem().FromClr(typeof (object)), new MediaType(mediaType)), score, matchingParameters);71 TypeSystems.Default.FromClr(typeof (object)), new MediaType(mediaType)), score, matchingParameters); 72 72 } 73 73 } -
trunk/src/core/OpenRasta.Tests.Unit/Codecs/CodecRepository_Specification.cs
r348 r429 152 152 public class when_searching_for_content_type_writers_for_a_media_type : codec_repository_context 153 153 { 154 readonly ITypeSystem typeSystem = new ReflectionBasedTypeSystem();154 readonly ITypeSystem typeSystem = TypeSystems.Default; 155 155 new IList<CodecRegistration> ThenTheResult; 156 156 … … 264 264 public CodecRegistration ThenTheResult; 265 265 public CodecMatch ThenTheResultScoring; 266 public ITypeSystem TypeSystem = new ReflectionBasedTypeSystem();266 public ITypeSystem TypeSystem = TypeSystems.Default; 267 267 268 268 [SetUp] … … 286 286 Codecs.Add(CodecRegistration.FromResourceType(resourceType, 287 287 typeof(TCodec), 288 new ReflectionBasedTypeSystem(),288 TypeSystems.Default, 289 289 mediaType, 290 290 null, -
trunk/src/core/OpenRasta.Tests.Unit/Codecs/MultipartFormDataCodec_Specification.cs
r426 r429 303 303 DependencyManager.Codecs, 304 304 DependencyManager.GetService<IDependencyResolver>(), 305 new ReflectionBasedTypeSystem(),305 TypeSystems.Default, 306 306 new DefaultObjectBinderLocator()); 307 307 } -
trunk/src/core/OpenRasta.Tests.Unit/Codecs/media_type_reader_context.cs
r369 r429 79 79 var codec = codecInstance as IMediaTypeReader; 80 80 if (codec != null) 81 _theResult = codec.ReadFrom(Context.Request.Entity, new ReflectionBasedTypeSystem().FromClr(typeof(T)), paramName);81 _theResult = codec.ReadFrom(Context.Request.Entity,TypeSystems.Default.FromClr(typeof(T)), paramName); 82 82 else 83 83 { -
trunk/src/core/OpenRasta.Tests.Unit/Configuration/LegacyManualConfiguration_Specification.cs
r420 r429 33 33 match.ShouldNotBeNull(); 34 34 match.UriCulture.ShouldBe(language); 35 match.ResourceKey.ShouldBe( new ReflectionBasedTypeSystem().FromClr(typeof(TResource)));35 match.ResourceKey.ShouldBe(TypeSystems.Default.FromClr(typeof(TResource))); 36 36 match.UriName.ShouldBe(name); 37 37 } … … 77 77 { 78 78 return 79 DependencyManager.Codecs.Where(codec => codec.ResourceType.CompareTo( new ReflectionBasedTypeSystem().FromClr(typeof (TResource)))==0 && codec.CodecType == typeof (TCodec) && codec.MediaType.MediaType == mediaType).79 DependencyManager.Codecs.Where(codec => codec.ResourceType.CompareTo(TypeSystems.Default.FromClr(typeof (TResource)))==0 && codec.CodecType == typeof (TCodec) && codec.MediaType.MediaType == mediaType). 80 80 Distinct().SingleOrDefault(); 81 81 } … … 179 179 var handlerMatch = DependencyManager.Handlers.GetHandlerTypesFor(urimatch.ResourceKey).FirstOrDefault(); 180 180 handlerMatch.ShouldNotBeNull(); 181 handlerMatch.ShouldBe( new ReflectionBasedTypeSystem().FromClr(typeof(THandler)));181 handlerMatch.ShouldBe(TypeSystems.Default.FromClr(typeof(THandler))); 182 182 return handlerMatch; 183 183 } -
trunk/src/core/OpenRasta.Tests.Unit/Configuration/MetaModelHandler_Specification.cs
r362 r429 136 136 137 137 Handler.Process(MetaModel); 138 var typeSystem = new ReflectionBasedTypeSystem().FromClr(typeof(Customer));138 var typeSystem = TypeSystems.Default.FromClr(typeof(Customer)); 139 139 var registeredHandlers = HandlerRepository.GetHandlerTypesFor(typeSystem); 140 140 … … 146 146 void given_handler_registration() 147 147 { 148 var typeSystem = new ReflectionBasedTypeSystem();148 var typeSystem = TypeSystems.Default; 149 149 MetaModel.ResourceRegistrations.Add(new ResourceModel 150 150 { … … 160 160 public class when_registering_non_IType_resource_keys : metamodelhandler_context<TypeRewriterMetaModelHandler> 161 161 { 162 ReflectionBasedTypeSystem TypeSystem;163 164 protected override void SetUp() 165 { 166 base.SetUp(); 167 TypeSystem = new ReflectionBasedTypeSystem();162 ITypeSystem TypeSystem; 163 164 protected override void SetUp() 165 { 166 base.SetUp(); 167 TypeSystem = TypeSystems.Default; 168 168 Handler = new TypeRewriterMetaModelHandler(TypeSystem); 169 169 } … … 238 238 void given_unknown_type_registered_as_codec() 239 239 { 240 var typeSystem = new ReflectionBasedTypeSystem();240 var typeSystem = TypeSystems.Default; 241 241 MetaModel.ResourceRegistrations.Add(new ResourceModel 242 242 { … … 251 251 void given_codec_registration() 252 252 { 253 var typeSystem = new ReflectionBasedTypeSystem();253 var typeSystem = TypeSystems.Default; 254 254 MetaModel.ResourceRegistrations.Add(new ResourceModel 255 255 { -
trunk/src/core/OpenRasta.Tests.Unit/Configuration/MetaModel_Specification.cs
r381 r429 89 89 public void a_resource_with_IType_is_registered() 90 90 { 91 ResourceSpaceHas.ResourcesOfType( new ReflectionBasedTypeSystem().FromClr(typeof(Customer)));91 ResourceSpaceHas.ResourcesOfType(TypeSystems.Default.FromClr(typeof(Customer))); 92 92 93 93 MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBeOfType<IType>().Name.ShouldBe("Customer"); … … 209 209 { 210 210 ResourceSpaceHas.ResourcesOfType(typeof(Frodo)).AtUri("/theshrine") 211 .HandledBy( new ReflectionBasedTypeSystem().FromClr(typeof(CustomerHandler)));211 .HandledBy(TypeSystems.Default.FromClr(typeof(CustomerHandler))); 212 212 FirstRegistration.Handlers[0].Name.ShouldBe("CustomerHandler"); 213 213 } -
trunk/src/core/OpenRasta.Tests.Unit/Fakes/Customer.cs
r300 r429 25 25 { 26 26 public List<Order> Orders { get; set; } 27 public ICollection<string> Attributes { get; set; } 27 28 } 28 29 -
trunk/src/core/OpenRasta.Tests.Unit/OpenRasta.Tests.Unit.csproj
r426 r429 121 121 <Compile Include="TypeSystem\PropertyPathManager_Specification.cs" /> 122 122 <Compile Include="TypeSystem\ReflectionExtensions_Specification.cs" /> 123 <Compile Include="TypeSystem\Surrogate2_Specification.cs" /> 123 124 <Compile Include="TypeSystem\Surrogates_Specification.cs" /> 124 125 <Compile Include="Text\Rfc2047Encoding_Specification.cs" /> -
trunk/src/core/OpenRasta.Tests.Unit/OperationModel/CodecSelectors/RequestCodecSelector_Specification.cs
r317 r429 4 4 using System.Runtime.InteropServices; 5 5 using NUnit.Framework; 6 using OpenRasta.Binding; 6 7 using OpenRasta.Codecs; 7 8 using OpenRasta.OperationModel; … … 9 10 using OpenRasta.OperationModel.Hydrators; 10 11 using OpenRasta.Testing; 12 using OpenRasta.Tests.Unit.Fakes; 11 13 using OpenRasta.Tests.Unit.OperationModel.Filters; 12 14 using OpenRasta.Web; … … 76 78 FilteredOperations.First(x => x.Name == "Get").GetRequestCodec().ShouldBeNull(); 77 79 } 80 [Test] 81 public void operations_with_partially_filled_members_still_get_codec_assigned() 82 { 83 given_filter(); 84 given_operations(); 85 given_request_header_content_type(MediaType.ApplicationXWwwFormUrlencoded); 86 87 given_registration_codec<ApplicationXWwwFormUrlencodedKeyedValuesCodec>(); 88 given_request_entity_body("firstname=Frodo"); 89 90 given_operation_property(x => x.Name == "GetFrodo", "lastname", "baggins"); 91 92 when_filtering_operations(); 93 94 FilteredOperations.First(x => x.Name == "GetFrodo").GetRequestCodec() 95 .ShouldNotBeNull() 96 .CodecRegistration.CodecType 97 .ShouldBe<ApplicationXWwwFormUrlencodedKeyedValuesCodec>(); 98 } 99 100 void given_operation_property(Func<IOperation, bool> predicate, string propertyName, string propertyValue) 101 { 102 Operations.First(predicate).Inputs.First().Binder.SetProperty( 103 propertyName, 104 new object[]{propertyValue}, 105 (v,t)=>BindingResult.Success(v)); 106 } 78 107 } 79 108 public class when_a_codec_is_not_found : requestcodecselector_context … … 117 146 } 118 147 public void GetWithOptionalValue([Optional]int optionalIndex){} 148 149 public void GetFrodo(Frodo frodo) 150 { 151 152 } 119 153 } 120 154 } -
trunk/src/core/OpenRasta.Tests.Unit/Settings.StyleCop
r300 r429 53 53 </RuleSettings> 54 54 </Rule> 55 <Rule Name="ElementsMustBeSeparatedByBlankLine">56 <RuleSettings>57 <BooleanProperty Name="Enabled">False</BooleanProperty>58 </RuleSettings>59 </Rule>60 55 </Rules> 61 56 <AnalyzerSettings /> … … 163 158 </RuleSettings> 164 159 </Rule> 165 <Rule Name="FieldNamesMustNotContainUnderscore">166 <RuleSettings>167 <BooleanProperty Name="Enabled">False</BooleanProperty>168 </RuleSettings>169 </Rule>170 160 </Rules> 171 161 <AnalyzerSettings /> … … 278 268 </RuleSettings> 279 269 </Rule> 280 <Rule Name="SplitParametersMustStartOnLineAfterDeclaration">281 <RuleSettings>282 <BooleanProperty Name="Enabled">False</BooleanProperty>283 </RuleSettings>284 </Rule>285 270 <Rule Name="ParametersMustBeOnSameLineOrSeparateLines"> 286 <RuleSettings>287 <BooleanProperty Name="Enabled">False</BooleanProperty>288 </RuleSettings>289 </Rule>290 <Rule Name="ParameterMustNotSpanMultipleLines">291 271 <RuleSettings> 292 272 <BooleanProperty Name="Enabled">False</BooleanProperty> -
trunk/src/core/OpenRasta.Tests.Unit/TypeSystem/Instances_Specification.cs
r314 r429 16 16 using OpenRasta.Testing; 17 17 using OpenRasta.Tests.Unit.Fakes; 18 18 19 using OpenRasta.TypeSystem; 19 20 using OpenRasta.TypeSystem.ReflectionBased; 21 using Frodo=OpenRasta.Tests.Unit.Fakes.Frodo; 20 22 21 23 namespace Instances_Specification … … 26 28 public void cannot_assign_properties_to_a_null_object() 27 29 { 28 GivenTypeInstance<Customer>();29 30 Executing(() => T henTypeBuilder.Apply(null)).ShouldThrow<ArgumentNullException>();30 given_builder_for<Customer>(); 31 32 Executing(() => TypeBuilder.Update(null)).ShouldThrow<ArgumentNullException>(); 31 33 } 32 34 … … 34 36 public void the_properties_are_assigned() 35 37 { 36 GivenTypeInstance<Customer>();37 GivenProperty("username", "johndoe");38 given_builder_for<Customer>(); 39 given_property("username", "johndoe"); 38 40 39 41 var newCustomer = new Customer {FirstName = "John"}; 40 42 41 T henTypeBuilder.Apply(newCustomer);43 TypeBuilder.Update(newCustomer); 42 44 43 45 newCustomer.Username.ShouldBe("johndoe"); 44 46 newCustomer.FirstName.ShouldBe("John"); 45 47 46 GivenProperty("lastname", "doe");48 given_property("lastname", "doe"); 47 49 newCustomer = new Customer {FirstName = "John"}; 48 T henTypeBuilder.Apply(newCustomer);50 TypeBuilder.Update(newCustomer); 49 51 50 52 newCustomer.Username.ShouldBe("johndoe"); … … 59 61 public void a_property_retrieved_twice_retrieves_the_same_object() 60 62 { 61 GivenTypeInstance<string>();62 63 T henTypeBuilder.GetProperty("Length").ShouldBeTheSameInstanceAs(ThenTypeBuilder.GetProperty("Length"));63 given_builder_for<string>(); 64 65 TypeBuilder.GetProperty("Length").ShouldBeTheSameInstanceAs(TypeBuilder.GetProperty("Length")); 64 66 } 65 67 … … 67 69 public void a_readonly_property_is_returned_as_non_writable() 68 70 { 69 GivenTypeInstance<string>();70 71 T henTypeBuilder.GetProperty("Length").CanWrite.ShouldBeFalse();71 given_builder_for<string>(); 72 73 TypeBuilder.GetProperty("Length").CanWrite.ShouldBeFalse(); 72 74 } 73 75 … … 75 77 public void an_unknown_property_returns_null() 76 78 { 77 GivenTypeInstance<string>();78 79 T henTypeBuilder.GetProperty("unknown").ShouldBeNull();79 given_builder_for<string>(); 80 81 TypeBuilder.GetProperty("unknown").ShouldBeNull(); 80 82 } 81 83 } … … 86 88 public void a_property_retrieved_but_wihtout_a_value_is_not_present_in_the_changes() 87 89 { 88 GivenTypeInstance<Customer>();89 90 T henTypeBuilder.GetProperty("FirstName")90 given_builder_for<Customer>(); 91 92 TypeBuilder.GetProperty("FirstName") 91 93 .TrySetValue(2).ShouldBeFalse(); 92 94 93 T henTypeBuilder.Changes.Count.ShouldBe(0);95 TypeBuilder.Changes.Count.ShouldBe(0); 94 96 } 95 97 … … 97 99 public void a_successfully_assigned_property_is_present_in_the_list_of_changes() 98 100 { 99 GivenTypeInstance<Customer>();100 101 T henTypeBuilder.GetProperty("FirstName").TrySetValue("Frodo");102 103 T henTypeBuilder.Changes.Count.ShouldBe(1);104 T henTypeBuilder.Changes.ContainsKey("FirstName").ShouldBeTrue();101 given_builder_for<Customer>(); 102 103 TypeBuilder.GetProperty("FirstName").TrySetValue("Frodo"); 104 105 TypeBuilder.Changes.Count.ShouldBe(1); 106 TypeBuilder.Changes.ContainsKey("FirstName").ShouldBeTrue(); 105 107 } 106 108 … … 108 110 public void accessing_the_indexer_with_an_unknown_key_throws() 109 111 { 110 GivenTypeInstance<Customer>();111 Executing(() => { IPropertyBuilder value = T henTypeBuilder.Changes["firstname"]; })112 given_builder_for<Customer>(); 113 Executing(() => { IPropertyBuilder value = TypeBuilder.Changes["firstname"]; }) 112 114 .ShouldThrow<ArgumentOutOfRangeException>(); 113 115 } … … 116 118 public void the_change_list_is_readonly() 117 119 { 118 GivenTypeInstance<Customer>();119 120 T henTypeBuilder.Changes.IsReadOnly.ShouldBeTrue();121 Executing(() => T henTypeBuilder.Changes.Add(null, null))120 given_builder_for<Customer>(); 121 122 TypeBuilder.Changes.IsReadOnly.ShouldBeTrue(); 123 Executing(() => TypeBuilder.Changes.Add(null, null)) 122 124 .ShouldThrow<NotSupportedException>(); 123 125 124 Executing(() => T henTypeBuilder.Changes.Remove(null))126 Executing(() => TypeBuilder.Changes.Remove(null)) 125 127 .ShouldThrow<NotSupportedException>(); 126 128 127 Executing(() => T henTypeBuilder.Changes["bla"] = null)129 Executing(() => TypeBuilder.Changes["bla"] = null) 128 130 .ShouldThrow<NotSupportedException>(); 129 131 } … … 132 134 public void the_keys_are_case_insensitive() 133 135 { 134 GivenTypeInstance<Customer>();135 T henTypeBuilder.GetProperty("FirstName")136 given_builder_for<Customer>(); 137 TypeBuilder.GetProperty("FirstName") 136 138 .TrySetValue("Frodo"); 137 T henTypeBuilder.Changes["firstname"].Value.ShouldBe("Frodo");139 TypeBuilder.Changes["firstname"].Value.ShouldBe("Frodo"); 138 140 } 139 141 } … … 144 146 public void a_property_is_not_set_when_the_type_is_incompatible() 145 147 { 146 GivenTypeInstance<Customer>();147 148 T henTypeBuilder.GetProperty("Username").TrySetValue(3).ShouldBeFalse();148 given_builder_for<Customer>(); 149 150 TypeBuilder.GetProperty("Username").TrySetValue(3).ShouldBeFalse(); 149 151 } 150 152 … … 152 154 public void a_writable_property_is_set_and_its_value_can_be_retrieved() 153 155 { 154 GivenTypeInstance<Customer>();155 156 T henTypeBuilder.GetProperty("Username").TrySetValue("hello")156 given_builder_for<Customer>(); 157 158 TypeBuilder.GetProperty("Username").TrySetValue("hello") 157 159 .ShouldBeTrue(); 158 160 159 T henTypeBuilder.GetProperty("Username")161 TypeBuilder.GetProperty("Username") 160 162 .Value.ShouldBe("hello"); 161 163 } … … 172 174 public void a_new_instance_is_created_when_using_create() 173 175 { 174 GivenTypeInstance<Customer>();175 Customer customer = T henTypeBuilder.Create().ShouldBeOfType<Customer>().ShouldNotBeNull();176 177 T henTypeBuilder.GetProperty("FirstName").TrySetValue("Frodo")176 given_builder_for<Customer>(); 177 Customer customer = TypeBuilder.Create().ShouldBeOfType<Customer>().ShouldNotBeNull(); 178 179 TypeBuilder.GetProperty("FirstName").TrySetValue("Frodo") 178 180 .ShouldBeTrue(); 179 181 180 182 customer.LastName = "Baggins"; 181 customer = T henTypeBuilder.Create() as Customer;183 customer = TypeBuilder.Create() as Customer; 182 184 183 185 customer.FirstName.ShouldBe("Frodo"); … … 188 190 public void assigning_properties_after_the_property_got_assigned_a_parent_updates_the_parent() 189 191 { 190 GivenTypeInstance<Customer>(); 192 given_builder_for<Customer>(); 193 191 194 var customerInstance = new Customer(); 192 T henTypeBuilder.TrySetValue(customerInstance);193 194 IPropertyBuilder firstName = T henTypeBuilder.GetProperty("FirstName");195 firstName.SetOwner(ThenTypeBuilder);195 TypeBuilder.TrySetValue(customerInstance); 196 197 IPropertyBuilder firstName = TypeBuilder.GetProperty("FirstName"); 198 //firstName.SetOwner(TypeBuilder); 196 199 197 200 firstName.TrySetValue(new[] {"Smeagol"}, IdentityConverter); 198 201 202 TypeBuilder.Update(customerInstance); 199 203 customerInstance.FirstName.ShouldBe("Smeagol"); 200 204 } 201 205 202 206 [Test] 203 public void cannot_assign_a_null_parent_to_a_property()204 {205 GivenTypeInstance<Customer>();206 Executing(() => ThenTypeBuilder.GetProperty("FirstName").SetOwner(null))207 .ShouldThrow<ArgumentNullException>();208 }209 210 [Test]211 public void cannot_assign_a_parent_twice()212 {213 GivenTypeInstance<Customer>();214 ThenTypeBuilder.GetProperty("FirstName").SetOwner(ThenTypeBuilder);215 ITypeBuilder newBuilder = new ReflectionBasedType(typeof(Customer)).CreateBuilder();216 Executing(() => ThenTypeBuilder.GetProperty("FirstName").SetOwner(newBuilder))217 .ShouldThrow<InvalidOperationException>();218 }219 220 [Test]221 207 public void no_reference_is_kept_after_a_call_to_apply() 222 208 { 223 GivenTypeInstance<Customer>();209 given_builder_for<Customer>(); 224 210 var customer = new Customer(); 225 T henTypeBuilder.Apply(customer);226 227 T henTypeBuilder.GetProperty("FirstName").TrySetValue("Frodo")211 TypeBuilder.Update(customer); 212 213 TypeBuilder.GetProperty("FirstName").TrySetValue("Frodo") 228 214 .ShouldBeTrue(); 229 215 230 object newCustomer = T henTypeBuilder.Create();216 object newCustomer = TypeBuilder.Create(); 231 217 newCustomer.ShouldNotBeTheSameInstanceAs(customer); 232 218 customer.FirstName.ShouldBe(null); … … 245 231 void WhenCreatingTheObject() 246 232 { 247 _result = T henTypeBuilder.Create();233 _result = TypeBuilder.Create(); 248 234 } 249 235 … … 251 237 public void a_type_instance_can_be_applied_twice() 252 238 { 253 GivenTypeInstance<Customer>();254 GivenProperty("Username", "johndoe");255 256 WhenCreatingTheObject(); 257 258 GivenProperty("FirstName", "John");239 given_builder_for<Customer>(); 240 given_property("Username", "johndoe"); 241 242 WhenCreatingTheObject(); 243 244 given_property("FirstName", "John"); 259 245 WhenCreatingTheObject(); 260 246 … … 266 252 public void a_value_can_be_assigned_to_the_type_instance() 267 253 { 268 GivenTypeInstance<int>();269 270 T henTypeBuilder.TrySetValue(3)254 given_builder_for<int>(); 255 256 TypeBuilder.TrySetValue(3) 271 257 .ShouldBeTrue(); 272 T henTypeBuilder.HasValue.ShouldBeTrue();273 T henTypeBuilder.Value.ShouldBe(3);258 TypeBuilder.HasValue.ShouldBeTrue(); 259 TypeBuilder.Value.ShouldBe(3); 274 260 } 275 261 … … 277 263 public void a_value_of_the_incorrect_type_cannot_be_assinged() 278 264 { 279 GivenTypeInstance<int>();280 281 T henTypeBuilder.TrySetValue("hello")265 given_builder_for<int>(); 266 267 TypeBuilder.TrySetValue("hello") 282 268 .ShouldBeFalse(); 283 269 284 ThenTypeBuilder.HasValue.ShouldBeFalse(); 285 } 286 287 [Test] 288 public void creating_an_object_twice_returns_the_same_object() 289 { 290 GivenTypeInstance<Customer>(); 291 ThenTypeBuilder.Create().ShouldBeTheSameInstanceAs(ThenTypeBuilder.Create()); 292 } 293 270 TypeBuilder.HasValue.ShouldBeFalse(); 271 } 294 272 [Test] 295 273 public void nested_properties_are_assigned() 296 274 { 297 GivenTypeInstance<Customer>();298 GivenProperty("Address.Line1", "Cadbury Street");299 GivenProperty("Address.City", "London");275 given_builder_for<Customer>(); 276 given_property("Address.Line1", "Cadbury Street"); 277 given_property("Address.City", "London"); 300 278 301 279 WhenCreatingTheObject(); … … 308 286 public void setting_properties_on_children_of_indexers_works_as_expected() 309 287 { 310 GivenTypeInstance<House>();311 312 GivenProperty("CustomersByName:john.FirstName", "John");313 GivenProperty("CustomersByName:john.LastName", "Doe");288 given_builder_for<House>(); 289 290 given_property("CustomersByName:john.FirstName", "John"); 291 given_property("CustomersByName:john.LastName", "Doe"); 314 292 WhenCreatingTheObject(); 315 293 ThenTheObject<House>().CustomersByName["john"].FirstName.ShouldBe("John"); … … 320 298 public void the_properties_are_assigned() 321 299 { 322 GivenTypeInstance<Customer>();323 GivenProperty("Username", "johndoe");324 GivenProperty("FirstName", "john");300 given_builder_for<Customer>(); 301 given_property("Username", "johndoe"); 302 given_property("FirstName", "john"); 325 303 326 304 WhenCreatingTheObject(); … … 330 308 } 331 309 332 public class when_assigning_a_value_to_a_parameter_binder : parameter_instance_context 333 { 334 [Test] 335 public void the_parameter_has_a_value() 336 { 337 GivenParameterInstance((int a) => { }); 338 GivenBinderKey("a", 1); 339 340 TheParameter.IsReadyForAssignment.ShouldBeTrue(); 341 } 342 } 343 344 public class when_not_assigning_a_value_to_a_parameter : parameter_instance_context 345 { 346 public void MethodWithOptional([Optional] int a) 347 { 348 } 349 350 [Test] 351 public void an_optional_value_gives_the_parameter_a_value() 352 { 353 GivenParameterInstance<int>(MethodWithOptional); 354 355 TheParameter.IsReadyForAssignment.ShouldBeTrue(); 356 } 357 358 [Test] 359 public void an_unfilled_parameter_doesnt_have_value() 360 { 361 GivenParameterInstance((int a) => { }); 362 363 TheParameter.IsReadyForAssignment.ShouldBeFalse(); 364 } 365 } 366 367 public class parameter_instance_context : instance_context 368 { 369 protected ParameterInstance TheParameter; 370 371 protected void GivenBinderKey<TValue>(string key, TValue value) 372 { 373 TheParameter.Binder.SetProperty(key, new[] {value}, (src, output) => BindingResult.Success(src)) 374 .ShouldBeTrue(); 375 } 376 377 protected void GivenParameterInstance<T>(Action<T> action) 378 { 379 var parameterType = new ReflectionBasedTypeSystem().FromClr(action.Method.GetParameters()[0].ParameterType); 380 TheParameter = new ParameterInstance(new ReflectionParameter(action.Method.GetParameters()[0]), 381 new KeyedValuesBinder( 382 parameterType, 383 action.Method.GetParameters()[0].Name)); 384 } 385 } 386 387 public class instance_context : context 388 { 310 311 public abstract class instance_context : context 312 { 313 protected static ITypeSystem _ts = TypeSystems.Default; 314 public instance_context() 315 { 316 } 389 317 // ITypeSystem _typeSystem = new 390 public void GivenTypeInstance<T1>()391 { 392 T henTypeBuilder = new ReflectionBasedTypeSystem().FromClr(typeof(T1)).CreateBuilder();393 } 394 395 protected ITypeBuilder T henTypeBuilder;396 397 protected void GivenProperty(string prop, object value)398 { 399 T henTypeBuilder.GetProperty(prop).TrySetValue(value).ShouldBeTrue();318 public void given_builder_for<T1>() 319 { 320 TypeBuilder = _ts.FromClr(typeof(T1)).CreateBuilder(); 321 } 322 323 protected ITypeBuilder TypeBuilder; 324 325 protected void given_property(string prop, object value) 326 { 327 TypeBuilder.GetProperty(prop).TrySetValue(value).ShouldBeTrue(); 400 328 } 401 329 } -
trunk/src/core/OpenRasta.Tests.Unit/TypeSystem/Members_Specification.cs
r362 r429 20 20 using OpenRasta.TypeSystem; 21 21 using OpenRasta.TypeSystem.ReflectionBased; 22 using OpenRasta.TypeSystem.ReflectionBased.Surrogates;23 22 24 23 namespace Accessors_Specification … … 29 28 public void a_reference_type_can_be_assigned_a_null_value() 30 29 { 31 new ReflectionBasedType( typeof(string)).CanSetValue(null)30 new ReflectionBasedType(_typeSystem,typeof(string)).CanSetValue(null) 32 31 .ShouldBe(true); 33 32 } … … 36 35 public void a_reflection_type_cannot_be_equal_to_null() 37 36 { 38 new ReflectionBasedType( typeof(string)).Equals(null)37 new ReflectionBasedType(_typeSystem,typeof(string)).Equals(null) 39 38 .ShouldBeFalse(); 40 39 } … … 44 43 { 45 44 object result; 46 new ReflectionBasedType( typeof(string)).TryCreateInstance(new[] { "value" }, (str, type) => BindingResult.Success(str), out result)45 new ReflectionBasedType(_typeSystem,typeof(string)).TryCreateInstance(new[] { "value" }, (str, type) => BindingResult.Success(str), out result) 47 46 .ShouldBeTrue(); 48 47 result.ShouldBe("value"); … … 53 52 { 54 53 object result; 55 new ReflectionBasedType( typeof(string)).TryCreateInstance(new[] { "value" }, (str, type) => BindingResult.Failure(), out result)54 new ReflectionBasedType(_typeSystem,typeof(string)).TryCreateInstance(new[] { "value" }, (str, type) => BindingResult.Failure(), out result) 56 55 .ShouldBeFalse(); 57 56 } … … 60 59 public void a_value_type_cannot_be_assigned_a_null_value() 61 60 { 62 new ReflectionBasedType( typeof(int)).CanSetValue(null)61 new ReflectionBasedType(_typeSystem,typeof(int)).CanSetValue(null) 63 62 .ShouldBeFalse(); 64 63 } … … 67 66 public void an_incorrect_type_cannot_be_assigned() 68 67 { 69 new ReflectionBasedType( typeof(int)).CanSetValue("hello")68 new ReflectionBasedType(_typeSystem,typeof(int)).CanSetValue("hello") 70 69 .ShouldBeFalse(); 71 70 } … … 81 80 public void the_name_is_the_type_name() 82 81 { 83 new ReflectionBasedType( typeof(string)).Name82 new ReflectionBasedType(_typeSystem,typeof(string)).Name 84 83 .ShouldBe("String"); 85 84 } … … 88 87 public void two_reflection_based_types_are_equal_if_built_from_the_same_native_type() 89 88 { 90 var type1 = new ReflectionBasedType( typeof(string));91 var type2 = new ReflectionBasedType( typeof(string));89 var type1 = new ReflectionBasedType(_typeSystem,typeof(string)); 90 var type2 = new ReflectionBasedType(_typeSystem,typeof(string)); 92 91 type1.Equals(type2).ShouldBeTrue(); 93 92 type1.GetHashCode().ShouldBe(type2.GetHashCode()); … … 97 96 public void two_reflection_based_types_are_not_equal_if_built_from_different_native_types() 98 97 { 99 var type1 = new ReflectionBasedType( typeof(string));100 var type2 = new ReflectionBasedType( typeof(object));98 var type1 = new ReflectionBasedType(_typeSystem,typeof(string)); 99 var type2 = new ReflectionBasedType(_typeSystem,typeof(object)); 101 100 type1.Equals(type2).ShouldBeFalse(); 102 101 type1.GetHashCode().ShouldNotBe(type2.GetHashCode()); … … 109 108 public void a_type_compared_to_a_null_results_in_minus_one() 110 109 { 111 new ReflectionBasedType( typeof(int)).CompareTo(null)110 new ReflectionBasedType(_typeSystem,typeof(int)).CompareTo(null) 112 111 .ShouldBe(-1); 113 112 } … … 116 115 public void two_types_not_in_an_inheritance_hierarchy_compare_to_minus_one() 117 116 { 118 new ReflectionBasedType( typeof(int)).CompareTo(new ReflectionBasedType(typeof(string)))117 new ReflectionBasedType(_typeSystem,typeof(int)).CompareTo(new ReflectionBasedType(_typeSystem,typeof(string))) 119 118 .ShouldBe(-1); 120 119 } … … 144 143 { 145 144 GivenTypeFor<Type>(); 146 ThenTheProperty("Namespace.Length").T argetType.ShouldBe<int>();145 ThenTheProperty("Namespace.Length").Type.Equals<int>().ShouldBeTrue(); 147 146 } 148 147 … … 152 151 GivenTypeFor<string>(); 153 152 154 ThenTheProperty("Length").T argetType.ShouldBe<int>();153 ThenTheProperty("Length").Type.Equals<int>().ShouldBeTrue(); 155 154 } 156 155 … … 159 158 { 160 159 GivenTypeFor<House>(); 161 ThenTheProperty("Customers:0.FirstName").T argetType.ShouldBe<string>();160 ThenTheProperty("Customers:0.FirstName").Type.Equals<string>().ShouldBeTrue(); 162 161 } 163 162 … … 180 179 { 181 180 GivenTypeFor<House>(); 182 ThenTheProperty("Customers:0").T argetType.ShouldBe<Customer>();181 ThenTheProperty("Customers:0").Type.Equals<Customer>().ShouldBeTrue(); 183 182 } 184 183 … … 232 231 } 233 232 234 ReflectionBasedProperty ThenTheProperty(string propertyName)235 { 236 return T henTheType.GetProperty(propertyName) as ReflectionBasedProperty;233 IProperty ThenTheProperty(string propertyName) 234 { 235 return Type.FindPropertyByPath(propertyName); 237 236 } 238 237 } … … 257 256 GivenTypeFor<RingOfPower>(); 258 257 259 var wornByMethod = T henTheType.GetMethod("WornBy");258 var wornByMethod = Type.GetMethod("WornBy"); 260 259 wornByMethod 261 260 .ShouldNotBeNull() … … 271 270 GivenTypeFor<RingOfPower>(); 272 271 273 T henTheType.GetMethod("WornBy")274 .ShouldBeTheSameInstanceAs(T henTheType.GetMethod("wornby"));272 Type.GetMethod("WornBy") 273 .ShouldBeTheSameInstanceAs(Type.GetMethod("wornby")); 275 274 } 276 275 [Test] … … 279 278 GivenTypeFor<RingOfPower>(); 280 279 281 T henTheType.GetMethod("ToString").Owner.TypeName.ShouldBe("Object");282 } 283 protected ICollection<IMethod> TheMethods { get { return T henTheType.GetMethods(); } }280 Type.GetMethod("ToString").Owner.TypeName.ShouldBe("Object"); 281 } 282 protected ICollection<IMethod> TheMethods { get { return Type.GetMethods(); } } 284 283 } 285 284 … … 292 291 public class when_building_types_from_the_type_system : context 293 292 { 294 readonly ITypeSystem TypeSystem = new ReflectionBasedTypeSystem();293 readonly ITypeSystem TypeSystem = TypeSystems.Default; 295 294 296 295 [Test] … … 311 310 public class IType_context : context 312 311 { 313 protected IType ThenTheType; 312 313 protected ITypeSystem _typeSystem; 314 315 public IType_context() 316 { 317 _typeSystem = TypeSystems.Default; 318 } 319 protected IType Type; 314 320 315 321 protected void GivenTypeFor<TTarget>() 316 322 { 317 T henTheType = TypeForClr<TTarget>();323 Type = TypeForClr<TTarget>(); 318 324 } 319 325 320 326 protected IType TypeForClr<TTarget>() 321 327 { 322 return new ReflectionBasedTypeSystem { SurrogateFactory = new DefaultSurrogateFactory() }.FromClr(typeof(TTarget));328 return _typeSystem.FromClr(typeof(TTarget)); 323 329 } 324 330 } -
trunk/src/core/OpenRasta.Tests.Unit/TypeSystem/Surrogates_Specification.cs
r314 r429 11 11 12 12 using System; 13 using System.Collections; 13 14 using System.Collections.Generic; 15 using System.Linq; 14 16 using Instances_Specification; 15 17 using NUnit.Framework; 16 18 using OpenRasta.Testing; 17 19 using OpenRasta.Tests.Unit.Fakes; 20 18 21 using OpenRasta.TypeSystem; 19 22 using OpenRasta.TypeSystem.ReflectionBased; 23 using Frodo = OpenRasta.Tests.Unit.Fakes.Frodo; 20 24 21 25 namespace Surrogates_Specification 22 26 { 23 public class when_using_ListOfT : context 27 28 public class when_using_ListOfT : instance_context 24 29 { 25 30 ITypeBuilder _theBuilder; … … 28 33 public void indexer_values_are_ignored_and_values_are_appended() 29 34 { 30 GivenTypeInstance();35 given_builder(); 31 36 32 37 _theBuilder.GetProperty(":1").TrySetValue("hello").ShouldBeTrue(); 33 38 _theBuilder.GetProperty(":0").TrySetValue("hello2").ShouldBeTrue(); 34 39 35 var theList = (List<string>) _theBuilder.Create();40 var theList = (List<string>)_theBuilder.Create(); 36 41 theList[0].ShouldBe("hello"); 37 42 theList[1].ShouldBe("hello2"); … … 40 45 public void the_indexer_is_surrogated() 41 46 { 42 GivenTypeInstance();47 given_builder(); 43 48 44 49 _theBuilder.GetProperty(":0").TrySetValue("hello") 45 50 .ShouldBeTrue(); 46 51 47 var theList = (List<string>) _theBuilder.Create();52 var theList = (List<string>)_theBuilder.Create(); 48 53 theList[0].ShouldBe("hello"); 49 54 } 50 55 51 void GivenTypeInstance()52 { 53 _theBuilder = new ReflectionBasedTypeSystem().FromClr(typeof(List<string>)).CreateBuilder();54 } 55 } 56 57 public class when_using_ListOfT_as_a_nested_property : context56 void given_builder() 57 { 58 _theBuilder = _ts.FromClr(typeof(List<string>)).CreateBuilder(); 59 } 60 } 61 62 public class when_using_ListOfT_as_a_nested_property : instance_context 58 63 { 59 64 ITypeBuilder _theBuilder; … … 67 72 .ShouldBeTrue(); 68 73 69 var theList = (ListContainer) _theBuilder.Create();74 var theList = (ListContainer)_theBuilder.Create(); 70 75 theList.ListOfStrings[0].ShouldBe("hello"); 71 76 } … … 73 78 public void indexer_value_is_ignored_when_surrogate_is_an_intermediary() 74 79 { 75 var instance = new ReflectionBasedTypeSystem().FromClr(typeof(House)).CreateBuilder();80 var instance = _ts.FromClr(typeof(House)).CreateBuilder(); 76 81 77 82 instance.GetProperty("Customers:4.FirstName").TrySetValue("Anakin"); … … 83 88 void GivenTypeInstance() 84 89 { 85 _theBuilder = new ReflectionBasedTypeSystem().FromClr(typeof(ListContainer)).CreateBuilder();90 _theBuilder = _ts.FromClr(typeof(ListContainer)).CreateBuilder(); 86 91 } 87 92 … … 93 98 public class when_using_surrogated_property : instance_context 94 99 { 95 100 96 101 } 97 102 public class when_using_DateTime_surrogate : instance_context … … 102 107 public void nested_surrogate_types_are_used_for_read_only_properties() 103 108 { 104 GivenTypeInstance<Customer>();105 GivenProperty("DateOfBirth.Day", 14);106 GivenProperty("DateOfBirth.Month", 12);107 108 WhenCreatingTheObject();109 110 ThenTheObject<Customer>().DateOfBirth.Day.ShouldBe(14);111 ThenTheObject<Customer>().DateOfBirth.Month.ShouldBe(12);109 given_builder_for<Customer>(); 110 given_property("DateOfBirth.Day", 14); 111 given_property("DateOfBirth.Month", 12); 112 113 when_creating_object(); 114 115 result_as<Customer>().DateOfBirth.Day.ShouldBe(14); 116 result_as<Customer>().DateOfBirth.Month.ShouldBe(12); 112 117 } 113 118 … … 115 120 public void surrogate_types_are_used_for_read_only_properties() 116 121 { 117 GivenTypeInstance<DateTime>(); 118 GivenProperty("Day", 14); 119 120 WhenCreatingTheObject(); 121 122 ThenTheObject<DateTime>().Day.ShouldBe(14); 123 } 124 125 T ThenTheObject<T>() 126 { 127 return (T) _result; 128 } 129 130 void WhenCreatingTheObject() 131 { 132 _result = ThenTypeBuilder.Create(); 122 given_builder_for<DateTime>(); 123 given_property("Day", 14); 124 125 when_creating_object(); 126 127 result_as<DateTime>().Day.ShouldBe(14); 128 } 129 130 T result_as<T>() 131 { 132 return (T)_result; 133 } 134 135 void when_creating_object() 136 { 137 _result = TypeBuilder.Create(); 138 } 139 140 } 141 public class indexer_for_enumerates : context.indexer_context<IEnumerable<string>,string> 142 { 143 [Test] 144 public void values_are_generated() 145 { 146 given_builder(); 147 given_successful_property(":0", "zero"); 148 given_successful_property(":1", "one"); 149 given_successful_property(":3", "three"); 150 151 when_object_built(); 152 153 then_values_should_be("zero","one","three"); 154 } 155 } 156 157 public class collection_for_enumerates : context.indexer_context<ICollection<string>, string> 158 { 159 [Test] 160 public void values_are_generated() 161 { 162 given_builder(); 163 given_successful_property(":0", "zero"); 164 given_successful_property(":1", "one"); 165 given_successful_property(":3", "three"); 166 167 when_object_built(); 168 169 then_values_should_be("zero", "one", "three"); 170 } 171 } 172 173 public class list_for_enumerates : context.indexer_context<IList<string>, string> 174 { 175 [Test] 176 public void values_are_generated() 177 { 178 given_builder(); 179 given_successful_property(":0", "zero"); 180 given_successful_property(":1", "one"); 181 given_successful_property(":3", "three"); 182 183 when_object_built(); 184 185 then_values_should_be("zero", "one", "three"); 186 } 187 } 188 public class Replicator : List<Frodo>{} 189 public class using_enumerable_types_with_indexer_surrogates : context.indexer_context<Replicator,Frodo> 190 { 191 public void multiple_values_are_added_to_the_same_object() 192 { 193 given_builder(); 194 given_successful_property(":0.FirstName", "Frodo"); 195 given_successful_property(":0.LastName", "Baggins"); 196 197 when_object_built(); 198 199 result.First().FirstName.ShouldBe("Frodo"); 200 result.First().LastName.ShouldBe("Baggins"); 201 } 202 } 203 namespace context 204 { 205 public class indexer_context<T,TValue> : OpenRasta.Testing.context 206 where T:IEnumerable<TValue> 207 { 208 protected static ITypeSystem TypeSystem = TypeSystems.Default; 209 protected ITypeBuilder builder; 210 protected T result; 211 212 protected void given_builder() 213 { 214 builder = TypeSystem.FromClr<T>().CreateBuilder(); 215 } 216 protected void given_successful_property(string key, object value) 217 { 218 builder.GetProperty(key).TrySetValue(value).ShouldBeTrue(); 219 } 220 protected void when_object_built() 221 { 222 result = (T)builder.Create(); 223 } 224 protected void then_values_should_be(params object[] values) 225 { 226 for (int i = 0; i < values.Length; i++) 227 { 228 result.Skip(i).FirstOrDefault().ShouldBe(values[i]); 229 } 230 } 133 231 } 134 232 } -
trunk/src/core/OpenRasta.Tests.Unit/Web/Handlers/HandlerRepository_Specification.cs
r362 r429 15 15 public void canoot_add_the_same_handler_type_twice_to_the_same_key() 16 16 { 17 var type = new ReflectionBasedTypeSystem().FromClr(typeof(string));17 var type = TypeSystems.Default.FromClr(typeof(string)); 18 18 var repo = new HandlerRepository(); 19 19 … … 26 26 public void two_handlers_can_be_registered_for_the_same_key() 27 27 { 28 var handler1 = new ReflectionBasedTypeSystem().FromClr(typeof(Sauron));29 var handler2 = new ReflectionBasedTypeSystem().FromClr(typeof(Frodo));28 var handler1 = TypeSystems.Default.FromClr(typeof(Sauron)); 29 var handler2 = TypeSystems.Default.FromClr(typeof(Frodo)); 30 30 31 31 var repo = new HandlerRepository(); … … 40 40 public void the_first_handler_is_returned_when_two_handlers_are_registered_for_the_same_key() 41 41 { 42 var handler1 = new ReflectionBasedTypeSystem().FromClr(typeof(Sauron));43 var handler2 = new ReflectionBasedTypeSystem().FromClr(typeof(Frodo));42 var handler1 = TypeSystems.Default.FromClr(typeof(Sauron)); 43 var handler2 = TypeSystems.Default.FromClr(typeof(Frodo)); 44 44 45 45 var repo = new HandlerRepository(); … … 55 55 var repo = new HandlerRepository(); 56 56 57 Executing(() => repo.AddResourceHandler(null, new ReflectionBasedTypeSystem().FromClr(typeof(Frodo))))57 Executing(() => repo.AddResourceHandler(null, TypeSystems.Default.FromClr(typeof(Frodo)))) 58 58 .ShouldThrow<ArgumentNullException>(); 59 59 … … 63 63 var repo = new HandlerRepository(); 64 64 65 Executing(() => repo.AddResourceHandler(null, new ReflectionBasedTypeSystem().FromClr(typeof(Frodo))))65 Executing(() => repo.AddResourceHandler(null, TypeSystems.Default.FromClr(typeof(Frodo)))) 66 66 .ShouldThrow<ArgumentNullException>(); 67 67 } 68 68 public void the_same_handler_can_be_registered_for_two_resources() 69 69 { 70 var gilGalad = new ReflectionBasedTypeSystem().FromClr(typeof(GilGalad));70 var gilGalad = TypeSystems.Default.FromClr(typeof(GilGalad)); 71 71 72 72 var repo = new HandlerRepository(); … … 80 80 public void enumerating_over_the_list_of_handlers_will_only_return_distinct_handlers() 81 81 { 82 var gilGalad = new ReflectionBasedTypeSystem().FromClr(typeof(GilGalad));82 var gilGalad = TypeSystems.Default.FromClr(typeof(GilGalad)); 83 83 84 84 var repo = new HandlerRepository(); -
trunk/src/core/OpenRasta.Tests.Unit/Web/Markup/SelectElement_Specification.cs
r323 r429 20 20 namespace SelectElement_Specification 21 21 { 22 public class when_the re_is_a_value: markup_element_context<ISelectElement>22 public class when_the_property_returns_a_value_for_enumerations : markup_element_context<ISelectElement> 23 23 { 24 public AttributeTargets PropertyReturningFalse { get{ return AttributeTargets.Interface;} } 24 public AttributeTargets PropertyReturningFalse 25 { 26 get{ return AttributeTargets.Interface; } 27 } 28 [Test] 25 29 public void the_option_element_is_selected() 26 30 { … … 33 37 } 34 38 } 35 //public class when_setting_a_value_before_adding_option_elements : context 36 //{ 37 // [Test] 38 // public void the_value_is_stored() 39 // { 40 // var element = new SelectElement(); 41 // element.Value = "25"; 42 // element.Children.Add(new OptionElement {Content = "26"}); 43 // element.Value.ShouldBe("25"); 44 // } 45 // [Test] 46 // public void the_selected_property_is_set_on_the_option_element() 47 // { 48 // var element = new SelectElement(); 49 // element.Value = "25"; 50 // element.Children.Add(new OptionElement {Content = "25"}); 51 // element.Children.First().Selected.ShouldBe(true); 52 // } 53 // [Test] 54 // public void the_selected_property_on_the_option_element_is_reset_if_the_assigned_value_is_different() 55 // { 39 public class when_building_an_option_tag : context 40 { 41 [Test] 42 public void the_markup_for_selected_options_is_correct() 43 { 44 var element = Document.CreateElement<IOptionElement>().Value("value")["content"]; 45 element.Selected = true; 46 element.ToString().ShouldBe("<option value=\"value\" selected=\"selected\">content</option>"); 47 } 48 [Test] 49 public void the_markup_for_not_selected_options_is_correct() 50 { 56 51 57 // var element = new SelectElement(); 58 // element.Value = "25"; 59 // element.Children.Add(new OptionElement { Content = "26", Selected = true }); 60 // element.Children.First().Selected.ShouldBe(false); 61 // } 62 // [Test] 63 // public void rendering_the_element_when_the_value_doesnt_match_an_option_results_in_an_error() 64 // { 65 // var element = new SelectElement() {Value = "24"}; 66 // element.Children.Add(new OptionElement {Content = "25"}); 67 // Executing(() => element.ToString()) 68 // .ShouldThrow<InvalidOperationException>(); 69 // } 70 //} 71 //public class when_setting_a_value_after_adding_option_elements : context 72 //{ 73 // [Test] 74 // public void the_value_is_stored() 75 // { 76 // var element = new SelectElement(); 77 // element.Children.Add(new OptionElement { Content = "26" }); 78 // element.Value = "25"; 79 // element.Value.ShouldBe("25"); 80 // } 81 // [Test] 82 // public void the_selected_property_is_set_on_the_option_element() 83 // { 84 85 // var element = new SelectElement(); 86 // element.Children.Add(new OptionElement { Content = "25" }); 87 // element.Value = "25"; 88 // element.Children.First().Selected.ShouldBe(true); 89 // } 90 // [Test] 91 // public void the_value_is_stored_after_removing_an_option_element() 92 // { 93 // var element = new SelectElement(); 94 // element.Children.Add(new OptionElement { Content = "25" }); 95 // element.Value = "25"; 96 97 // element.Children.RemoveAt(0); 98 // element.Value.ShouldBe("25"); 99 // } 100 //} 52 var element = Document.CreateElement<IOptionElement>().Value("value")["content"]; 53 element.Selected = false; 54 element.ToString().ShouldBe("<option value=\"value\">content</option>"); 55 } 56 } 101 57 } 102 58 -
trunk/src/core/OpenRasta.Tests.Unit/Web/Pipeline/Contributors/ResponseEntityWriter_Specification.cs
r362 r429 94 94 Context.PipelineData.ResponseCodec = CodecRegistration.FromResourceType(typeof(object), 95 95 typeof(TCodec), 96 new ReflectionBasedTypeSystem(),96 TypeSystems.Default, 97 97 new MediaType("application/unknown"), 98 98 null, -
trunk/src/core/OpenRasta.Tests.Unit/Web/TemplatedUriResolver_Specification.cs
r412 r429 19 19 using OpenRasta.Tests.Unit.Fakes; 20 20 using OpenRasta.TypeSystem; 21 using OpenRasta.TypeSystem.ReflectionBased; 21 22 using OpenRasta.Web; 22 23 … … 33 34 when_matching_uri("https://localhost/Valinor/Olorin"); 34 35 35 matching_result36 var resourceKey = matching_result 36 37 .ShouldNotBeNull() 37 .ResourceKey.ShouldBeOfType<IType>() 38 .ResourceKey; 39 resourceKey.ShouldBeOfType<IType>() 38 40 .Equals<Gandalf>().ShouldBeTrue(); 39 41 } … … 55 57 when_creating_uri<IConvertible>("location2", null); 56 58 57 ThenTheResult.ShouldBe("http://localhost/location2");59 Result.ShouldBe("http://localhost/location2"); 58 60 } 59 61 … … 67 69 when_creating_uri<object>(new NameValueCollection { { "variable1", "injected1" } }); 68 70 69 ThenTheResult.ToString().ShouldBe("http://localhost/test/injected1");71 Result.ToString().ShouldBe("http://localhost/test/injected1"); 70 72 } 71 73 … … 77 79 when_creating_uri<IList<object>>(new NameValueCollection { { "variable1", "injected1" } }); 78 80 79 ThenTheResult.ToString().ShouldBe("http://localhost/test/injected1");81 Result.ToString().ShouldBe("http://localhost/test/injected1"); 80 82 } 81 83 … … 90 92 when_creating_uri<IList<object>>(new NameValueCollection { { "variable1", "injected1" } }); 91 93 92 ThenTheResult.ToString().ShouldBe("http://localhost/test?query=injected1");94 Result.ToString().ShouldBe("http://localhost/test?query=injected1"); 93 95 } 94 96 … … 101 103 when_creating_uri<IConvertible>(null); 102 104 103 ThenTheResult.ShouldBe("http://localhost/location1");105 Result.ShouldBe("http://localhost/location1"); 104 106 } 105 107 … … 112 114 when_creating_uri<Frodo>(null); 113 115 114 ThenTheResult.ShouldBe("http://localhost/theshire");116 Result.ShouldBe("http://localhost/theshire"); 115 117 } 116 118 [Test] … … 121 123 when_creating_uri<Frodo>("http://localhost/lotr/".ToUri(), null); 122 124 123 ThenTheResult.ShouldBe("http://localhost/lotr/theshire");125 Result.ShouldBe("http://localhost/lotr/theshire"); 124 126 } 125 127 … … 131 133 when_creating_uri<Frodo>("http://localhost/lotr".ToUri(), null); 132 134 133 ThenTheResult.ShouldBe("http://localhost/lotr/theshire");135 Result.ShouldBe("http://localhost/lotr/theshire"); 134 136 } 135 137 } … … 141 143 protected TemplatedUriResolver Resolver; 142 144 143 protected Uri ThenTheResult; 145 protected Uri Result; 146 ITypeSystem TypeSystem; 144 147 148 public templated_uri_resolver_context() 149 { 150 TypeSystem = TypeSystems.Default; 151 } 145 152 [SetUp] 146 153 public void before_each_behavior() 147 154 { 148 ThenTheResult = null;155 Result = null; 149 156 Resolver = new TemplatedUriResolver(); 150 157 } 151 158 protected void when_creating_uri<T>(Uri baseUri, NameValueCollection templateParameters) 152 159 { 153 ThenTheResult = Resolver.CreateUriFor(baseUri, typeof(T), templateParameters);160 Result = Resolver.CreateUriFor(baseUri, typeof(T), templateParameters); 154 161 } 155 162 156 163 protected void given_uri_mapping(string uri, Type type, CultureInfo cultureInfo, string alias) 157 164 { 158 Resolver.Add(new UriRegistration(uri, type, alias, cultureInfo));165 Resolver.Add(new UriRegistration(uri, TypeSystem.FromClr(type), alias, cultureInfo)); 159 166 } 160 167 161 168 protected void when_creating_uri<T1>(NameValueCollection nameValueCollection) 162 169 { 163 ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), nameValueCollection);170 Result = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), nameValueCollection); 164 171 } 165 172 166 173 protected void when_creating_uri<T1>(string uriName, NameValueCollection nameValueCollection) 167 174 { 168 ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), uriName, nameValueCollection);175 Result = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), uriName, nameValueCollection); 169 176 } 170 177 } -
trunk/src/core/OpenRasta.Tests.Unit/openrasta_context.cs
r420 r429 5 5 using System.IO; 6 6 using System.Text; 7 using OpenRasta.Binding.Path; 7 8 using OpenRasta.Codecs; 8 9 using OpenRasta.Collections; … … 28 29 public openrasta_context() 29 30 { 30 TypeSystem = new ReflectionBasedTypeSystem();31 TypeSystem = TypeSystems.Default; 31 32 } 32 33 … … 146 147 { 147 148 var bytes = Encoding.UTF8.GetBytes(content); 148 Request.Entity = new HttpEntity( new HttpHeaderDictionary(), new MemoryStream(bytes)) { ContentLength = bytes.Length };149 Request.Entity = new HttpEntity(Request.Entity.Headers, new MemoryStream(bytes)) { ContentLength = bytes.Length }; 149 150 } 150 151 … … 208 209 Resolver.AddDependency<IAuthenticationProvider, InMemAuthenticationProvider>(); 209 210 Resolver.AddDependencyInstance(typeof(IErrorCollector), Errors = new TestErrorCollector()); 211 Resolver.AddDependency<IPathManager, DefaultPathManager>(); 210 212 211 213 manager.SetupCommunicationContext(Context = new InMemoryCommunicationContext()); -
trunk/src/core/OpenRasta/Binding/BinderBaseAttribute.cs
r314 r429 10 10 11 11 using System; 12 using OpenRasta.TypeSystem;13 12 14 13 namespace OpenRasta.Binding 15 14 { 16 [ AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]17 public abstract class BinderBaseAttribute : Attribute, IObjectBinderLocator15 [Obsolete("The type was renamed. Please use BinderAttribute instead.")] 16 public abstract class BinderBaseAttribute : BinderAttribute 18 17 { 19 public abstract IObjectBinder GetBinder(IMember parameterInfo);20 18 } 21 19 } -
trunk/src/core/OpenRasta/Binding/BindingResult.cs
r314 r429 11 11 namespace OpenRasta.Binding 12 12 { 13 /// <summary> 14 /// Represents the result of a binding. 15 /// </summary> 13 16 public class BindingResult 14 17 { … … 20 23 } 21 24 25 /// <summary> 26 /// Gets the instance of the built object. 27 /// </summary> 28 /// <remarks> 29 /// The value of this property is undefined when the binding has not been successful. 30 /// </remarks> 22 31 public object Instance { get; private set; } 32 33 /// <summary> 34 /// Gets a value defining if the binding was successful. 35 /// </summary> 23 36 public bool Successful { get; private set; } 24 37 38 /// <summary> 39 /// Creates a binding result for failing bindings. 40 /// </summary> 41 /// <returns></returns> 25 42 public static BindingResult Failure() 26 43 { … … 28 45 } 29 46 47 /// <summary> 48 /// Creates a binding result for successful bindings. 49 /// </summary> 50 /// <param name="instance">The object successful built by the binder.</param> 51 /// <returns>An instance of the <see cref="BindingResult"/> type.</returns> 30 52 public static BindingResult Success(object instance) 31 53 { -
trunk/src/core/OpenRasta/Binding/ChangeSetBinder.cs
r348 r429 15 15 namespace OpenRasta.Binding 16 16 { 17 /// <summary> 18 /// Represents a binder for the ChangeSet type. 19 /// </summary> 20 /// <typeparam name="T"></typeparam> 17 21 public class ChangeSetBinder<T> : KeyedValuesBinder where T : class 18 22 { 19 23 /// <summary> 20 /// Constructs a new binder for types of type ChangeSet.24 /// Constructs a new binder for types of type <see cref="ChangeSet"/>. 21 25 /// </summary> 22 26 /// <param name="type"></param> -
trunk/src/core/OpenRasta/Binding/DefaultObjectBinderLocator.cs
r362 r429 22 22 { 23 23 Logger = NullLogger.Instance; 24 TypeSystem = new ReflectionBasedTypeSystem();24 TypeSystem = TypeSystems.Default; 25 25 } 26 26 … … 30 30 public IObjectBinder GetBinder(IMember member) 31 31 { 32 BinderBaseAttribute binderAttribute = member.FindAttribute<BinderBaseAttribute>() ?? member.Type.FindAttribute<BinderBaseAttribute>();32 var abstractObjectBinderAttribute = member.FindAttribute<BinderAttribute>() ?? member.Type.FindAttribute<BinderAttribute>(); 33 33 34 if ( binderAttribute != null)35 return binderAttribute.GetBinder(member);34 if (abstractObjectBinderAttribute != null) 35 return abstractObjectBinderAttribute.GetBinder(member); 36 36 37 37 IMethod binderMethod = member.GetMethod("GetBinder"); -
trunk/src/core/OpenRasta/Binding/IObjectBinder.cs
r314 r429 13 13 namespace OpenRasta.Binding 14 14 { 15 /// <summary> 16 /// Represents a component able to build instances of objects from object paths and values. 17 /// </summary> 15 18 public interface IObjectBinder 16 19 { 20 /// <summary> 21 /// Gets a value defining if the binder contains any values. 22 /// </summary> 17 23 bool IsEmpty { get; } 24 25 /// <summary> 26 /// Gets the list of prefixes that the binder will ignore when parsing the keys and value pairs. 27 /// </summary> 18 28 ICollection<string> Prefixes { get; } 29 30 /// <summary> 31 /// Tries to set a property value based on a key and a list of values. 32 /// </summary> 33 /// <typeparam name="TValue">The type of values being used to assign to the destination property.</typeparam> 34 /// <param name="key">The object path to the property to assign.</param> 35 /// <param name="values">The values to be used in realizing the value for the property</param> 36 /// <param name="converter">The converter responsible for converting between the source values and the destination value.</param> 37 /// <returns><c>true</c> if the assignment was successful, otherwise <c>false</c>.</returns> 19 38 bool SetProperty<TValue>(string key, IEnumerable<TValue> values, ValueConverter<TValue> converter); 39 40 /// <summary> 41 /// Tries to set an instance as the object used when assigning values. 42 /// </summary> 43 /// <param name="builtInstance">The instance of an object being used for binding.</param> 44 /// <returns><c>true</c> if the assignment was successful, otherwise <c>false</c>.</returns> 20 45 bool SetInstance(object builtInstance); 46 47 /// <summary> 48 /// Attempts to build an object and return a <see cref="BindingResult"/> instance containing the result of the building. 49 /// </summary> 50 /// <returns>An instance of the <see cref="BindingResult"/> type containing the result of the binding.</returns> 21 51 BindingResult BuildObject(); 22 52 } -
trunk/src/core/OpenRasta/Binding/IObjectBinderLocator.cs
r314 r429 13 13 namespace OpenRasta.Binding 14 14 { 15 /// <summary> 16 /// Defines a component able to locate an object binder for a member. 17 /// </summary> 15 18 public interface IObjectBinderLocator 16 19 { 20 /// <summary> 21 /// Gets a binder for a member. 22 /// </summary> 23 /// <param name="member">The member for which to find a binder.</param> 24 /// <returns>An instance of an <see cref="IObjectBinder"/> defined for this member.</returns> 17 25 IObjectBinder GetBinder(IMember member); 18 26 } -
trunk/src/core/OpenRasta/Binding/KeyedValues.cs
r315 r429 1 1 namespace OpenRasta.Binding 2 2 { 3 /// <summary> 4 /// Represents a key and associated values. 5 /// </summary> 3 6 public abstract class KeyedValues 4 7 { 8 /// <summary> 9 /// The key for which a value is provided. 10 /// </summary> 5 11 public string Key { get; protected set; } 12 13 /// <summary> 14 /// Sets a value defining if the KeyedValue was used during the binding process. 15 /// </summary> 6 16 public bool WasUsed { get; protected set; } 17 18 /// <summary> 19 /// Tries to set the value on the provided object binder. 20 /// </summary> 21 /// <param name="binder">The <see cref="IObjectBinder"/> to use when applying the value.</param> 22 /// <returns><c>true</c> if the assignment was successful, otherwise <c>false</c>.</returns> 7 23 public abstract bool SetProperty(IObjectBinder binder); 8 24 } -
trunk/src/core/OpenRasta/Binding/KeyedValuesBinder.cs
r421 r429 11 11 using System; 12 12 using System.Collections.Generic; 13 using System.Linq;14 13 using OpenRasta.Binding.Path; 15 14 using OpenRasta.TypeSystem; … … 20 19 public class KeyedValuesBinder : IObjectBinder 21 20 { 21 readonly bool _isEnumerable; 22 22 readonly string _name; 23 23 readonly string _typeName; … … 25 25 object _cachedBuiltObject; 26 26 bool _isInstanceConstructed; 27 bool _isEnumerable;28 27 29 28 public KeyedValuesBinder(IType target) : this(target, target.Name) … … 33 32 public KeyedValuesBinder(IType target, string name) 34 33 { 35 TypeSystem = target.TypeSystem; 36 _isEnumerable = !target.Equals<string>() && target.Type.IsCollection; 34 _isEnumerable = !target.Equals<string>() && target.Type.IsEnumerable; 37 35 Builder = target.CreateBuilder(); 38 36 _name = name; … … 43 41 } 44 42 45 protected IPathManager PathManager { get; set; }46 47 43 public bool IsEmpty 48 44 { 49 get { return ! _isEnumerable && !Builder.HasValue; }45 get { return !Builder.HasValue; } 50 46 } 51 47 52 48 public ICollection<string> Prefixes { get; private set; } 53 49 54 public ITypeSystem TypeSystem { get; set; }55 56 50 protected ITypeBuilder Builder { get; private set; } 51 protected IPathManager PathManager { get; set; } 57 52 58 53 public virtual BindingResult BuildObject() … … 84 79 bool success; 85 80 86 if (keyType.Type == PathComponentType.Constructor)87 success = SetConstructorValue(values, converter);88 else89 success = SetPropertyValue(key, keyType.ParsedValue, values, converter);81 if (keyType.Type == PathComponentType.Constructor) 82 success = SetConstructorValue(values, converter); 83 else 84 success = SetPropertyValue(key, keyType.ParsedValue, values, converter); 90 85 91 86 if (!success) … … 101 96 bool SetPropertyValue<TValue>(string key, string property, IEnumerable<TValue> values, ValueConverter<TValue> converter) 102 97 { 103 IPropertyBuilder propertyBuilder = Builder.GetProperty(property ?? key);98 var propertyBuilder = Builder.GetProperty(property ?? key); 104 99 if (propertyBuilder == null) return false; 105 100 return propertyBuilder.TrySetValue(values, converter); -
trunk/src/core/OpenRasta/Binding/KeyedValuesBinderAttribute.cs
r314 r429 13 13 namespace OpenRasta.Binding 14 14 { 15 public class KeyedValuesBinderAttribute : Binder BaseAttribute15 public class KeyedValuesBinderAttribute : BinderAttribute 16 16 { 17 17 public override IObjectBinder GetBinder(IMember memberInfo) -
trunk/src/core/OpenRasta/Binding/KeyedValues`1.cs
r314 r429 15 15 { 16 16 /// <summary> 17 /// Represent a string key associated with a series of values and a converter, used to match key and values pairs with the keyvalue binder.17 /// Represent a key associated with a series of typed values and a converter, used to match key and values pairs with binders. 18 18 /// </summary> 19 19 /// <typeparam name="T">The type of the values.</typeparam> … … 28 28 Converter = converter; 29 29 } 30 30 31 31 32 public ValueConverter<T> Converter { get; private set; } -
trunk/src/core/OpenRasta/Binding/ValueConverter.cs
r314 r429 13 13 namespace OpenRasta.Binding 14 14 { 15 /// <summary> 16 /// Defines a conversion method used to convert entities between multiple types. 17 /// </summary> 18 /// <typeparam name="T">The type of the entity to convert.</typeparam> 19 /// <param name="entity">The entity instance to convert.</param> 20 /// <param name="entityType">The target Type</param> 21 /// <returns>The result of the conversion.</returns> 15 22 public delegate BindingResult ValueConverter<T>(T entity, Type entityType); 16 23 } -
trunk/src/core/OpenRasta/Codecs/CodecRepository.cs
r369 r429 38 38 } 39 39 40 public CodecRegistration FindByExtension(IMember resource Type, string extension)40 public CodecRegistration FindByExtension(IMember resourceMember, string extension) 41 41 { 42 42 foreach (var codecRegistration in _codecs) … … 45 45 if (codecRegistration.Extensions.Contains(extension, StringComparison.OrdinalIgnoreCase)) 46 46 { 47 if (codecRegistration.IsStrict && resource Type.CompareTo(codecResourceType) == 0)47 if (codecRegistration.IsStrict && resourceMember.Type.CompareTo(codecResourceType) == 0) 48 48 return codecRegistration; 49 49 50 if (resource Type.CompareTo(codecResourceType) >= 0)50 if (resourceMember.Type.CompareTo(codecResourceType) >= 0) 51 51 return codecRegistration; 52 52 } … … 129 129 } 130 130 131 static int CalculateDistance(IMember type, CodecRegistration registration)131 static int CalculateDistance(IMember member, CodecRegistration registration) 132 132 { 133 133 if (registration.ResourceType == null) 134 134 return -1; 135 135 if (registration.IsStrict) 136 return ( type.CompareTo(registration.ResourceType) == 0) ? 0 : -1;137 return type.CompareTo(registration.ResourceType);136 return (member.Type.CompareTo(registration.ResourceType) == 0) ? 0 : -1; 137 return member.Type.CompareTo(registration.ResourceType); 138 138 } 139 139 -
trunk/src/core/OpenRasta/Configuration/DefaultDependencyRegistrar.cs
r420 r429 15 15 using System.Reflection; 16 16 using OpenRasta.Binding; 17 using OpenRasta.Binding.Path; 17 18 using OpenRasta.Codecs; 18 19 using OpenRasta.CodeDom.Compiler; … … 33 34 using OpenRasta.TypeSystem; 34 35 using OpenRasta.TypeSystem.ReflectionBased; 36 using OpenRasta.TypeSystem.Surrogated; 37 using OpenRasta.TypeSystem.Surrogates; 38 using OpenRasta.TypeSystem.Surrogates.Static; 35 39 using OpenRasta.Web; 36 40 … … 39 43 public class DefaultDependencyRegistrar : IDependencyRegistrar 40 44 { 45 protected Type PathManagerType; 46 41 47 public DefaultDependencyRegistrar() 42 48 { … … 50 56 OperationHydratorTypes = new List<Type>(); 51 57 OperationCodecSelectorTypes = new List<Type>(); 52 58 SurrogateBuilders = new List<Type>(); 53 59 LogSourceTypes = new List<Type>(); 54 60 … … 65 71 SetOperationExecutor<OperationExecutor>(); 66 72 SetOperationInterceptorProvider<SystemAndAttributesOperationInterceptorProvider>(); 73 SetPathManager<DefaultPathManager>(); 67 74 68 75 AddMethodFilter<TypeExclusionMethodFilter<object>>(); … … 76 83 AddOperationCodecResolvers(); 77 84 AddLogSources(); 85 AddSurrogateBuilders(); 86 } 87 88 public void AddSurrogateBuilders() 89 { 90 SurrogateBuilders.Add(typeof(ListIndexerSurrogateBuilder)); 91 SurrogateBuilders.Add(typeof(DateTimeSurrogate)); 92 } 93 94 protected IList<Type> SurrogateBuilders { get; private set; } 95 96 public void SetPathManager<T>() 97 { 98 PathManagerType = typeof(T); 78 99 } 79 100 … … 186 207 { 187 208 RegisterCoreComponents(resolver); 209 RegisterSurrogateBuilders(resolver); 188 210 RegisterLogging(resolver); 189 211 RegisterMetaModelHandlers(resolver); 190 RegisterCodecs(resolver);191 212 RegisterContributors(resolver); 192 213 RegisterCodeSnippeModifiers(resolver); … … 194 215 RegisterOperationModel(resolver); 195 216 RegisterLogSources(resolver); 217 RegisterCodecs(resolver); 218 } 219 220 protected virtual void RegisterSurrogateBuilders(IDependencyResolver resolver) 221 { 222 SurrogateBuilders.ForEach(x => resolver.AddDependency(typeof(ISurrogateBuilder), x, DependencyLifetime.Transient)); 196 223 } 197 224 … … 257 284 resolver.AddDependency(typeof(IOperationExecutor), OperationExecutorType, DependencyLifetime.Transient); 258 285 resolver.AddDependency(typeof(IErrorCollector), ErrorCollectorType, DependencyLifetime.Transient); 259 resolver.AddDependency(typeof(IOperationInterceptorProvider), OperationInterceptorProviderType, DependencyLifetime.Singleton); 286 resolver.AddDependency(typeof(IOperationInterceptorProvider), OperationInterceptorProviderType, DependencyLifetime.Transient); 287 resolver.AddDependency(typeof(IPathManager), PathManagerType, DependencyLifetime.Singleton); 288 resolver.AddDependency(typeof(ISurrogateProvider), typeof(SurrogateBuilderProvider), DependencyLifetime.Singleton); 260 289 } 261 290 -
trunk/src/core/OpenRasta/Data/ChangeSet`1.cs
r362 r429 15 15 namespace OpenRasta.Data 16 16 { 17 /// <summary> 18 /// Represents a set of changes that can be applied to a type. 19 /// </summary> 20 /// <typeparam name="T"></typeparam> 17 21 public class ChangeSet<T> where T : class 18 22 { … … 22 26 } 23 27 28 /// <summary> 29 /// Gets the list of changes to be applied to an object.
