示例#1
0
        public void TestMethod_GetMessage_WithUserDefinedFields()
        {
            var classInfo = ClassInfo <Dummy> .Create(new Dictionary <string, object>
            {
                { MessageField, "CustomMessage" }
            });

            ExpressionTest <Dummy> .CreateTest(MessageField, classInfo, "CustomMessage").TestAndVerify();
        }
示例#2
0
        public void TestMethod_AddLongItems()
        {
            ExpressionTest <Dummy> .CreateTest(nameof(Dummy.AddLongItems), "_longList.Count", 50).TestAndVerify();

            TypeUtility.InitializeInstanceCollectionFields = false;

            ExpressionTest <Dummy> .CreateTest(nameof(Dummy.AddLongItems), "_longList.Count", 25).TestAndVerify();

            TypeUtility.InitializeInstanceCollectionFields = true;
        }
示例#3
0
        public void TestMethod_AddItem()
        {
            ExpressionTest <Dummy> .CreateTest(nameof(Dummy.AddItem), "_classList.Count", 26).TestAndVerify();

            TypeUtility.InitializeInstanceCollectionFields = false;

            ExpressionTest <Dummy> .CreateTest(nameof(Dummy.AddItem), "_classList.Count", 1).TestAndVerify();

            TypeUtility.InitializeInstanceCollectionFields = true;
        }
示例#4
0
        public void TestMethods_UsingExpressions()
        {
            var methods = new List <Expression <Dummy> >
            {
                Expression <Dummy> .Create(nameof(GetType), ExpressionTest <Dummy> .CreateTest("Name", "Dummy")),
                Expression <Dummy> .Create(nameof(GetType), ExpressionTest <Dummy> .CreateTest("GetFields[0].Name", "DummyClassType"))
            };

            _tester.TestAndVerifyMethods(methods);
        }
示例#5
0
        public void TestMethod_ReturnMessage()
        {
            // Arrange
            var methods = new List <Expression <Dummy> >
            {
                Expression <Dummy>
                .Create(nameof(Dummy.ReturnMessage), new object[] { "ExpressionTest-1", "ExpressionTest-2" },
                        ExpressionTest <Dummy> .CreateTest("ExpressionTest-1 ExpressionTest-2"))
            };

            // Assert
            _tester.TestAndVerifyMethods(methods);
        }
示例#6
0
        public void TestMethod_GetSquareRoot()
        {
            const double expectedOutput = 25.9422435421457;

            // Solution 1
            ExpressionTest <Dummy> .CreateTest(SquareRootMethod, expectedOutput).TestAndVerify();

            // Solution 2
            // Arrange
            var dummy = new Dummy();

            // Act
            var result = dummy.Evaluate <double>(SquareRootMethod);

            // Assert
            result.ShouldBe(expectedOutput);
        }
示例#7
0
 public void TestMethod_Message_ClassWithNoConstructor()
 {
     ExpressionTest <DummyWithNoConstructor> .CreateTest(nameof(DummyWithNoConstructor.Message), "Test_Message").TestAndVerify();
 }
示例#8
0
 public void TestMethod_ReturnCharacter()
 {
     ExpressionTest <Dummy> .CreateTest(nameof(Dummy.ReturnCharacter), 'a').TestAndVerify();
 }
示例#9
0
 public void TestMethod_WithUserDefinedParameters()
 {
     Expression <Dummy> .Create("ReturnMessage2", new object[] { "Test" }, ExpressionTest <Dummy> .CreateTest("Test")).TestAndVerify();
 }
示例#10
0
 public void TestMethod_WithNullParameters()
 {
     Expression <Dummy> .CreateWithNullParameters("ReturnMessage2", ExpressionTest <Dummy> .CreateTest(null)).TestAndVerify();
 }