Exemple #1
0
        private bool TestAddToList(int _TestStepNo)
        {
            PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> Testing AddElementsToArrayItem-1...");

            bool bLocalFailure = !SelectedDBService.AddElementsToArrayItem(
                TableName,
                Key, new BPrimitiveType("test_1"),
                "test_list", new BPrimitiveType[]
            {
                new BPrimitiveType("test_value_1"),
                new BPrimitiveType("test_value_2"),
                new BPrimitiveType("test_value_3"),
                new BPrimitiveType("test_value_4")
            },
                out JObject ReturnValue,
                EBReturnItemBehaviour.ReturnAllOld,
                null,
                (string Message) =>
            {
                Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message);
                bLocalFailure = true;
            });

            if (bLocalFailure)
            {
                PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> AddElementsToArrayItem-1 failed.");
                return(false);
            }
            PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> AddElementsToArrayItem-1 succeed. Returned: " + ReturnValue?.ToString());

            PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> Testing AddElementsToArrayItem-2. Expecting failure...");

            bLocalFailure = !SelectedDBService.AddElementsToArrayItem(
                TableName,
                Key, new BPrimitiveType("test_1"),
                "test_list", new BPrimitiveType[]
            {
                new BPrimitiveType("test_value_2"),
                new BPrimitiveType("test_value_5")
            },
                out ReturnValue,
                EBReturnItemBehaviour.ReturnAllOld,
                SelectedDBService.BuildArrayElementNotExistCondition(new BPrimitiveType("test_value_1")),
                (string Message) =>
            {
                Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message);
                bLocalFailure = true;
            });
            if (!bLocalFailure)
            {
                PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> AddElementsToArrayItem-2 did not fail.");
                return(false);
            }
            PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> AddElementsToArrayItem-2 successfully failed. Returned: " + ReturnValue?.ToString());

            bLocalFailure = !SelectedDBService.GetItem(
                TableName,
                Key, new BPrimitiveType("test_1"),
                new string[] { "test_list" },
                out ReturnValue,
                (string Message) =>
            {
                Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message);
                bLocalFailure = true;
            });
            if (bLocalFailure)
            {
                PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> GetItem-1 has failed.");
                return(false);
            }
            PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> GetItem-1 successfully completed. Returned: " + ReturnValue?.ToString());

            return(true);
        }