public void missing_property_mapping_throws() { var cfg = new DestinationConfiguration(typeof(Person)); cfg.From(typeof(PersonalInfo), typeof(Parents)); var bindable = configFactory.CreateBindableConfiguration(cfg.TakeSnapshot()); Action validation = bindable.Assert; validation.should_throw_an <DittoConfigurationException>(); validation.should_throw_because <DittoConfigurationException>("The following properties are not mapped for '" + typeof(Person) + "':" + Environment.NewLine + "FathersName" + Environment.NewLine); }
public void it_should_map_nested_components_by_type() { var componentConfig = new DestinationConfiguration(typeof(ViewModelComponent)); componentConfig.From(typeof(EventComponent)); var modelConfig = new DestinationConfiguration(typeof(ComplexViewModel)); modelConfig.From(typeof(ComplexEventWithDifferentNamedComponent)); modelConfig.SetPropertyResolver( PropertyNameCriterion.From <ComplexViewModel>(m => m.Component), typeof(ComplexEventWithDifferentNamedComponent), new RedirectingConfigurationResolver(MappableProperty.For <ComplexEventWithDifferentNamedComponent>(s => s.DifferentName), configFactory.CreateBindableConfiguration(componentConfig.TakeSnapshot()))); var bindable = configFactory.CreateBindableConfiguration(modelConfig.TakeSnapshot()); var source = new ComplexEventWithDifferentNamedComponent() { Name = "RootName", DifferentName = new EventComponent() { Name = "ComponentName" } }; var dest = new ComplexViewModel(); var executable = bindable.CreateExecutableMapping(typeof(ComplexEventWithDifferentNamedComponent)); executable.Execute(contextualizer.CreateContext(source, dest)); dest.Name.should_be_equal_to("RootName"); dest.Component.should_not_be_null(); dest.Component.Name.should_be_equal_to("ComponentName"); }
public collection_resolver_tests() { var factory = new TestConfigurationFactory(); var cfg = new DestinationConfiguration(typeof(IntegerDest)); cfg.From(typeof(IntegerSource)); integerComponentElementConfig = factory.CreateBindableConfiguration(cfg.TakeSnapshot()); contextualizer = new TestContextualizer(); }
public void it_should_determine_candidate_properties() { var modelConfig = new DestinationConfiguration(typeof(DestinationWithComponentArray)); modelConfig.From(typeof(SourceWithComponentArray)); var cfg = configFactory.CreateBindableConfiguration(modelConfig.TakeSnapshot()); var binder = new ListPropertyBinder(null); var candidates = binder.GetCandidateDestinationProperties(cfg); candidates.should_have_item_matching(its => its.PropertyType == typeof(IntegerDest[])); }