コード例 #1
0
        public void Test_GetValue_ShouldGetValueFromBO()
        {
            //---------------Set up test pack-------------------
            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
            FakeBO fakeBO = new FakeBO {
                FakeBOName = RandomValueGen.GetRandomString()
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(fakeBO.ID.ObjectID);
            //---------------Execute Test ----------------------
            var actualValue = propDescriptor.GetValue(fakeBO);

            //---------------Test Result -----------------------
            Assert.AreEqual(fakeBO.ID.ObjectID, actualValue);
        }
コード例 #2
0
        public void Test_GetValue_WhenComponentNotCorrectType_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                propDescriptor.GetValue(100);
                Assert.Fail("Expected to throw an InvalidCastException");
            }
            //---------------Test Result -----------------------
            catch (InvalidCastException ex)
            {
                StringAssert.Contains("You cannot GetValue since the component is not of type ", ex.Message);
            }
        }
コード例 #3
0
        public void Test_GetValue_WhenComponentNull_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
            object x = null;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                propDescriptor.GetValue(x);
                Assert.Fail("Expected to throw an ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("component", ex.ParamName);
                StringAssert.Contains("Value cannot be null.", ex.Message);
            }
        }
コード例 #4
0
        public void Test_GetValue_WhenComponentNull_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
            object x = null;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                propDescriptor.GetValue(x);
                Assert.Fail("Expected to throw an ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("component", ex.ParamName);
                StringAssert.Contains("Value cannot be null.", ex.Message);
            }
        }
コード例 #5
0
        public void Test_GetValue_WhenComponentNotCorrectType_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                propDescriptor.GetValue(100);
                Assert.Fail("Expected to throw an InvalidCastException");
            }
            //---------------Test Result -----------------------
            catch (InvalidCastException ex)
            {
                StringAssert.Contains("You cannot GetValue since the component is not of type ", ex.Message);
            }
        }
コード例 #6
0
 public void Test_GetValue_ShouldGetValueFromBO()
 {
     //---------------Set up test pack-------------------
     PropertyDescriptorID propDescriptor = new PropertyDescriptorID();
     FakeBO fakeBO = new FakeBO { FakeBOName = RandomValueGen.GetRandomString() };
     //---------------Assert Precondition----------------
     Assert.IsNotNull(fakeBO.ID.ObjectID);
     //---------------Execute Test ----------------------
     var actualValue = propDescriptor.GetValue(fakeBO);
     //---------------Test Result -----------------------
     Assert.AreEqual(fakeBO.ID.ObjectID, actualValue);
 }