public void a_resource_of_type_strict_is_registered_as_a_strict_type() { ResourceSpaceHas.ResourcesOfType <Strictly <Customer> >(); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBeOfType <Type>().ShouldBe <Customer>(); MetaModel.ResourceRegistrations[0].IsStrictRegistration.ShouldBeTrue(); }
public void a_handler_from_generic_type_is_registered() { ResourceSpaceHas.ResourcesOfType <Frodo>().AtUri("/theshrine") .HandledBy <CustomerHandler>(); FirstRegistration.Handlers[0].Name.ShouldBe("CustomerHandler"); }
public void using_resource_func_no_args() { // ReSharper disable once RedundantStringInterpolation ResourceSpaceHas.ResourcesOfType <Customer>().AtUri(c => $"/customer/"); TheUris[0].Uri.ShouldBe("/customer/"); }
public void a_uri_is_registered() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri("/customer"); TheUris.Count.ShouldBe(1); TheUris[0].Uri.ShouldBe("/customer"); }
public void a_resource_with_IType_is_registered() { ResourceSpaceHas.ResourcesOfType(TypeSystems.Default.FromClr(typeof(Customer))); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBeAssignableTo <IType>().Name.ShouldBe( "Customer"); }
public void a_handler_from_type_instance_is_registered() { ResourceSpaceHas.ResourcesOfType(typeof(Frodo)) .AtUri("/theshrine") .HandledBy(typeof(CustomerHandler)); FirstRegistration.Handlers[0].Type.Name.ShouldBe("CustomerHandler"); }
public void a_resource_by_generic_type_is_registered() { ResourceSpaceHas.ResourcesOfType <Customer>(); MetaModel.ResourceRegistrations.Count.ShouldBe(1); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBe(typeof(Customer)); }
public void cannot_add_a_null_handler() { Executing(() => ResourceSpaceHas.ResourcesOfType <Frodo>().AtUri("/theshrine").HandledBy((IType)null)) .ShouldThrow <ArgumentNullException>(); Executing(() => ResourceSpaceHas.ResourcesOfType <Frodo>().AtUri("/theshrine").HandledBy((Type)null)) .ShouldThrow <ArgumentNullException>(); }
public void a_resource_with_any_key_is_registered() { var key = new object(); ResourceSpaceHas.ResourcesWithKey(key); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBeTheSameInstanceAs(key); }
public void cannot_register_a_uri_then_without_a_uri() { Executing(() => { ICodecParentDefinition reg = ResourceSpaceHas.ResourcesOfType <Frodo>() .AtUri("/theshrine") .And.WithoutUri; }).ShouldThrow <InvalidOperationException>(); }
public void using_resource_func_with_var() { // TODO:Implement this correctly var stringVar = "test"; const string stringConst = "test2"; ResourceSpaceHas.ResourcesOfType <Customer>().AtUri(c => $"/customer/{c.Address}/{stringVar}/{stringConst}/{UriFuncProp}"); TheUris[0].Uri.ShouldBe("/customer/{Address}/test/test2/test3"); }
public void two_handlers_can_be_added() { ResourceSpaceHas.ResourcesOfType(typeof(Frodo)).AtUri("/theshrine") .HandledBy <CustomerHandler>() .And .HandledBy <object>(); FirstRegistration.Handlers[0].Name.ShouldBe("CustomerHandler"); FirstRegistration.Handlers[1].Name.ShouldBe("Object"); }
public void can_register_multiple_uris_for_a_resource() { ResourceSpaceHas.ResourcesOfType <Frodo>() .AtUri("/theshire") .And .AtUri("/lothlorien"); TheUris.Count.ShouldBe(2); TheUris[0].Uri.ShouldBe("/theshire"); TheUris[1].Uri.ShouldBe("/lothlorien"); }
public void a_uri_name_is_registered() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri("/customer").Named("default"); TheUris[0].Name.ShouldBe("default"); }
public void a_uri_language_is_registered() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri("/customer").InLanguage("fr"); TheUris[0].Language.Name.ShouldBe("fr"); }
public void using_resource_func_no_format() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri(c => "/customer/"); TheUris[0].Uri.ShouldBe("/customer/"); }
public void a_resource_can_be_registered_with_no_uri() { ICodecParentDefinition reg = ResourceSpaceHas.ResourcesOfType <Customer>().WithoutUri; TheUris.Count.ShouldBe(0); }
public void a_null_language_defaults_to_the_inviariant_culture() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri("/customer").InLanguage(null); TheUris[0].Language.ShouldBe(CultureInfo.InvariantCulture); }
public void using_resource_func() { ResourceSpaceHas.ResourcesOfType <Customer>().AtUri(c => $"/customer/{c.Address}"); TheUris[0].Uri.ShouldBe("/customer/{Address}"); }
public void cannot_register_a_resource_with_a_null_key() { Executing(() => ResourceSpaceHas.ResourcesWithKey(null)) .ShouldThrow <ArgumentNullException>(); }
public void a_resource_by_name_is_registered() { ResourceSpaceHas.ResourcesNamed("customers"); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBe("customers"); }
public void a_handler_from_itype_is_registered() { ResourceSpaceHas.ResourcesOfType(typeof(Frodo)).AtUri("/theshrine") .HandledBy(TypeSystems.Default.FromClr(typeof(CustomerHandler))); FirstRegistration.Handlers[0].Name.ShouldBe("CustomerHandler"); }
void ExecuteTest(Action <ICodecParentDefinition> test) { test(ResourceSpaceHas.ResourcesOfType <Frodo>().AtUri("/theshrine").HandledBy <CustomerHandler>()); MetaModel.ResourceRegistrations.Clear(); test(ResourceSpaceHas.ResourcesOfType <Frodo>().WithoutUri); }
public void cannot_register_codec_not_implementing_icodec() { Executing(() => ResourceSpaceHas.ResourcesOfType <Frodo>().WithoutUri.TranscodedBy(typeof(string))) .ShouldThrow <ArgumentOutOfRangeException>(); }
public void a_resource_by_type_is_registered() { ResourceSpaceHas.Resource(typeof(Customer)); MetaModel.ResourceRegistrations[0].ResourceKey.ShouldBe(typeof(Customer)); }
public void cannot_register_a_null_uri_for_a_resource() { Executing(() => ResourceSpaceHas.ResourcesOfType <Customer>().AtUri((string)null)).ShouldThrow <ArgumentNullException>(); }
void ExecuteTest(Action <ICodecParentDefinition> test) { test(ResourceSpaceHas.Resource <Frodo>().Uri("/theshrine").Handler <CustomerHandler>()); MetaModel.ResourceRegistrations.Clear(); test(ResourceSpaceHas.Resource <Frodo>().Anywhere); }