Exemplo n.º 1
0
        public void ShouldReturnValueFromCreatorWhenCreatingOne()
        {
            var container = new KeyedFactoryContainer <int, int>();

            container.RegisterFactory(5, 5);

            var value = container.CreateValue(5, factory => 3);

            Assert.AreEqual(3, value);
        }
Exemplo n.º 2
0
        public void ShouldPassToCreatorFactoryWithMatchingKeyWhenCreatingValue()
        {
            var container = new KeyedFactoryContainer <int, int>();

            container.RegisterFactory(5, 10);
            var someFactory = 0;

            container.CreateValue <object>(5, factory => { someFactory = factory; return(null); });

            Assert.AreEqual(10, someFactory);
        }
Exemplo n.º 3
0
        public void ShouldThrowWhenRegisteringNullKey()
        {
            var container = new KeyedFactoryContainer <object, object>();

            container.RegisterFactory(null, new object());
        }
Exemplo n.º 4
0
        public void ShouldThrowWhenRegisteringNullFactory()
        {
            var container = new KeyedFactoryContainer <int, object>();

            container.RegisterFactory(5, null);
        }
Exemplo n.º 5
0
        public void ShouldThrowWhenCreatingValueWithNullCreator()
        {
            var container = new KeyedFactoryContainer <object, int>();

            container.CreateValue <int>(new object(), null);
        }
Exemplo n.º 6
0
        public void ShouldThrowWhenCreatingValueWithNullKey()
        {
            var container = new KeyedFactoryContainer <object, int>();

            container.CreateValue(null, factory => factory);
        }
Exemplo n.º 7
0
        public void ShouldThrowWhenCreatingFromFactoryThatIsNotRegistered()
        {
            var container = new KeyedFactoryContainer <int, int>();

            container.CreateValue(5, factory => factory);
        }