Exemplo n.º 1
0
        public void TestEqualsFindTokenOperators()
        {
            OperatorBase equalsOperator = PolicyOperator.FromToken(("=_" + "Boolean_Boolean").GetHashCode());

            equalsOperator.Should().NotBeNull();

            equalsOperator = PolicyOperator.FromToken(("=_" + "Int32_Int32").GetHashCode());
            equalsOperator.Should().NotBeNull();

            equalsOperator = PolicyOperator.FromToken(("=_" + "String_String").GetHashCode());
            equalsOperator.Should().NotBeNull();
        }
        public void TestExecute_LogicalOr_AssertResults()
        {
            OperatorBase equalsOperator = PolicyOperator.FromToken(("=_" + "Boolean_Boolean").GetHashCode());

            equalsOperator.Should().NotBeNull();

            Assert.True(PolicyOperator <bool> .LOGICAL_OR.Execute(true, true));
            Assert.True(PolicyOperator <bool> .LOGICAL_OR.Execute(true, false));
            Assert.True(PolicyOperator <bool> .LOGICAL_OR.Execute(false, true));
            Assert.False(PolicyOperator <bool> .LOGICAL_OR.Execute(false, false));
        }
        public void TestExecute_NotEquals_Convertparamspecial_AssertResults()
        {
            Assert.False(PolicyOperator <Int64, Int64, bool> .NOT_EQUALS.Execute("00F74F1C4FE4E1762E".HexAsLong(), "f74f1c4fe4e1762e".HexAsLong()));
            Assert.False(PolicyOperator <Int64, String, bool> .NOT_EQUALS.Execute("00F74F1C4FE4E1762E".HexAsLong(), "f74f1c4fe4e1762e"));
            Assert.True(PolicyOperator <Int64, String, bool> .NOT_EQUALS.Execute("00F74F1C4FE4E17600".HexAsLong(), "f74f1c4fe4e1762e"));

            Delegate del = PolicyOperator <Int64, String, bool> .NOT_EQUALS.ExecuteRef;

            Assert.False((bool)del.DynamicInvoke(new object[] { "00F74F1C4FE4E1762E".HexAsLong(), "f74f1c4fe4e1762e" }));
            Assert.True((bool)del.DynamicInvoke(new object[] { "00F74F1C4FE4E17600".HexAsLong(), "f74f1c4fe4e1762e" }));


            var          tokenHashCode = "!=_Int32_String".GetHashCode();
            OperatorBase operatorBase  = PolicyOperator.FromToken(tokenHashCode);

            operatorBase.Should().NotBeNull();
        }