public void WillNotAddTypesWithDuplicateKeys()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            factory.AddIfMissing("key1", typeof(MockRegionBehavior));
            factory.AddIfMissing("key1", typeof(MockRegionBehavior));

            Assert.AreEqual(1, factory.Count());
        }
        public void CanCreateRegisteredType()
        {
            var expectedBehavior = new MockRegionBehavior();

            RegionBehaviorFactory factory = new RegionBehaviorFactory(new MockServiceLocator() { GetInstance = (t) => expectedBehavior });

            factory.AddIfMissing("key1", typeof(MockRegionBehavior));
            var behavior = factory.CreateFromKey("key1");

            Assert.AreSame(expectedBehavior, behavior);
        }
        public void CanRegisterType()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            factory.AddIfMissing("key1", typeof(MockRegionBehavior));
            factory.AddIfMissing("key2", typeof(MockRegionBehavior));

            Assert.AreEqual(2, factory.Count());
            Assert.IsTrue(factory.ContainsKey("key1"));
            
        }
        public void CreateWithUnknownKeyThrows()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            factory.CreateFromKey("Key1");
        }
        public void AddTypeThatDoesNotInheritFromIRegionBehaviorThrows()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            factory.AddIfMissing("key1", typeof(object));
        }