Example #1
0
        public bool Start()
        {
            PrintAction?.Invoke("BDatabaseServicesTest->Info-> Test is starting.");

            if (SelectedDBService == null)
            {
                PrintAction?.Invoke("BDatabaseServicesTest->Error-> Given SelectedDBService is null.");
                return(false);
            }

            if (TableName == null || TableName.Length == 0)
            {
                PrintAction?.Invoke("BDatabaseServicesTest->Error-> Given TableName is null or empty.");
                return(false);
            }

            if (Key == null || Key.Length == 0)
            {
                PrintAction?.Invoke("BDatabaseServicesTest->Error-> Given Key is null or empty.");
                return(false);
            }

            if (!SelectedDBService.HasInitializationSucceed())
            {
                PrintAction?.Invoke("BDatabaseServicesTest->Error-> Initialization failed.");
                return(false);
            }
            PrintAction?.Invoke("BDatabaseServicesTest->Log-> Initialization succeed.");

            PreCleanup();

            if (!TestPutItem(1))
            {
                return(false);
            }

            PrintAction?.Invoke("BDatabaseServicesTest->Log-> Conditional put item, expecting failure.");

            if (TestPutItem(2, SelectedDBService.BuildAttributeNotExistCondition(Key)))
            {
                return(false);
            }

            if (!TestGetItem(3))
            {
                return(false);
            }

            if (!TestUpdateItem(4))
            {
                return(false);
            }

            PrintAction?.Invoke("BDatabaseServicesTest->Log-> Conditional update item, expecting failure.");

            if (TestUpdateItem(5,
                               SelectedDBService.BuildAttributeEqualsCondition("Test_Attr_Key_2", new BPrimitiveType(345))))
            {
                return(false);
            }

            if (!TestUpdateItem(6,
                                SelectedDBService.BuildAttributeNotEqualsCondition("Test_Attr_Key_2", new BPrimitiveType(345))))
            {
                return(false);
            }

            if (!TestUpdateItem(7,
                                SelectedDBService.BuildAttributeGreaterOrEqualCondition("Test_Attr_Key_2", new BPrimitiveType(22))))
            {
                return(false);
            }

            if (!TestUpdateItem(8,
                                SelectedDBService.BuildAttributeGreaterCondition("Test_Attr_Key_2", new BPrimitiveType(21))))
            {
                return(false);
            }

            if (!TestUpdateItem(9,
                                SelectedDBService.BuildAttributeLessCondition("Test_Attr_Key_2", new BPrimitiveType(23))))
            {
                return(false);
            }

            if (!TestUpdateItem(10,
                                SelectedDBService.BuildAttributeLessOrEqualCondition("Test_Attr_Key_2", new BPrimitiveType(22))))
            {
                return(false);
            }

            if (TestUpdateItem(11,
                               SelectedDBService.BuildAttributeEqualsCondition("Test_Attr_Key_1", new BPrimitiveType("Test_Attr_Val_New_2"))))
            {
                return(false);
            }

            if (TestUpdateItem(12,
                               SelectedDBService.BuildAttributeNotEqualsCondition("Test_Attr_Key_1", new BPrimitiveType("Test_Attr_Val_New_1"))))
            {
                return(false);
            }

            if (!TestUpdateItem(13,
                                SelectedDBService.BuildAttributeEqualsCondition("Test_Attr_Key_1", new BPrimitiveType("Test_Attr_Val_New_1"))))
            {
                return(false);
            }

            if (!TestUpdateItem(14, null, true))
            {
                return(false);
            }

            if (!TestGetItem(15))
            {
                return(false);
            }

            if (!TestIncrement(16))
            {
                return(false);
            }

            if (!TestScanTable(17))
            {
                return(false);
            }

            if (!TestDeleteItem(18))
            {
                return(false);
            }

            if (!TestAddToList(19))
            {
                return(false);
            }

            if (!TestRemoveFromList(20))
            {
                return(false);
            }

            return(true);
        }