Ejemplo n.º 1
0
        public void GetInstance_OfAlreadyRegisteredType_ReturnsTheRegisteredInstance()
        {
            //ARRANGE
            string theInstanceToReturn = "test";
            Type   theTypeToRegister   = typeof(object);

            TypeMapping.Map(theTypeToRegister, theInstanceToReturn);
            //ACT
            var result = TypeMapping.Get(typeof(object));

            //ASSERT
            Assert.That(result, Is.SameAs(theInstanceToReturn));
        }
Ejemplo n.º 2
0
        public void GetInstanceT_OfNotARegisteredType_ReturnsNull()
        {
            //ARRANGE
            string theInstanceToReturn = "test";


            TypeMapping.Map <object>(theInstanceToReturn);
            //ACT
            var result = TypeMapping.Get <string>();

            //ASSERT
            Assert.That(result, Is.Null);
        }
Ejemplo n.º 3
0
        public void GetInstance_OfNotARegisteredType_ReturnsNull()
        {
            //ARRANGE
            string theInstanceToReturn = "test";
            Type   theTypeToRegister   = typeof(object);

            TypeMapping.Map(theTypeToRegister, theInstanceToReturn);
            //ACT
            var result = TypeMapping.Get(typeof(int));

            //ASSERT
            Assert.That(result, Is.Null);
        }
Ejemplo n.º 4
0
        public void RegisterType_OfANewType_CanRegister()
        {
            //ARRANGE
            string theInstanceToReturn = "test";
            Type   theTypeToRegister   = typeof(object);

            TypeMapping.Map(theTypeToRegister, theInstanceToReturn);

            //ACT
            var result = TypeMapping.Get(theTypeToRegister);

            //ASSERT
            Assert.That(result, Is.Not.Null);
        }
Ejemplo n.º 5
0
        public void RegisterTypeT_OfANewType_CanRegister()
        {
            //ARRANGE
            string theInstanceToReturn = "test";

            TypeMapping.Map <object>(theInstanceToReturn);

            //ACT
            var result = TypeMapping.Get <object, object>();

            //ASSERT

            Assert.That(result, Is.Not.Null);
        }
Ejemplo n.º 6
0
        public void GetInstanceT_OfAlreadyRegisteredType_ReturnsTheRegisteredInstance()
        {
            //ARRANGE
            string theInstanceToReturn = "test";


            TypeMapping.Map <object>(theInstanceToReturn);
            //ACT
            var result = TypeMapping.Get <object, object>();

            //ASSERT


            Assert.That(result, Is.SameAs(theInstanceToReturn));
        }
Ejemplo n.º 7
0
        public void GetInstanceT_OfRegisteredType_ReturnsValue()
        {
            //ARRANGE
            string theInstanceToReturn = "test";

            TypeMapping.Map <string>(theInstanceToReturn);

            //ACT
            var result = TypeMapping.Get <string>();

            //ASSERT
            Assert.That(result, Is.Not.Null);



            Assert.Multiple(() =>
            {
                Assert.That(result, Is.EqualTo("test"));
                Assert.That(result, Is.SameAs(theInstanceToReturn), "Not same instance");
            });
        }