コード例 #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));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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");
            });
        }