Ejemplo n.º 1
0
        public void ShouldGetTheMostSpecializedMapping()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            var genericAdapter = new MockRegionAdapter();
            var specializedAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), genericAdapter);
            regionAdapterMappings.RegisterMapping(typeof(ItemsControlDescendant), specializedAdapter);
            var returnedAdapter = regionAdapterMappings.GetMapping(typeof(ItemsControlDescendant));

            Assert.IsNotNull(returnedAdapter);
            Assert.AreSame(specializedAdapter, returnedAdapter);
        }
 private DelayedRegionCreationBehavior GetBehavior(DependencyObject control, MockRegionManagerAccessor accessor, MockRegionAdapter adapter)
 {
     var mappings = new RegionAdapterMappings();
     mappings.RegisterMapping(control.GetType(), adapter);
     var behavior = new DelayedRegionCreationBehavior(mappings);
     behavior.RegionManagerAccessor = accessor;
     behavior.TargetElement = control;
     return behavior;
 }
Ejemplo n.º 3
0
        public void ShouldGetMappingForDerivedTypesThanTheRegisteredOnes()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            var regionAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), regionAdapter);
            var returnedAdapter = regionAdapterMappings.GetMapping(typeof(ItemsControlDescendant));

            Assert.IsNotNull(returnedAdapter);
            Assert.AreSame(regionAdapter, returnedAdapter);
        }
Ejemplo n.º 4
0
        public void ShouldGetRegisteredMapping()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            Type registeredType = typeof(ItemsControl);
            var regionAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(registeredType, regionAdapter);
            var returnedAdapter = regionAdapterMappings.GetMapping(registeredType);

            Assert.IsNotNull(returnedAdapter);
            Assert.AreSame(regionAdapter, returnedAdapter);
        }
Ejemplo n.º 5
0
        public void NullControlThrows()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            var regionAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(null, regionAdapter);
        }
Ejemplo n.º 6
0
        public void RegisterAMappingThatAlreadyExistsThrows()
        {
            var regionAdapterMappings = new RegionAdapterMappings();
            var regionAdapter = new MockRegionAdapter();

            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), regionAdapter);
            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), regionAdapter);
        }
Ejemplo n.º 7
0
        public void NullAdapterThrows()
        {
            var regionAdapterMappings = new RegionAdapterMappings();

            regionAdapterMappings.RegisterMapping(typeof(ItemsControl), null);
        }