Esempio n. 1
0
        public void DeleteApp_By_AppOsID_Successful()
        {
            //Arrange
            TResult <bool> expectedResponse = new TResult <bool>
            {
                data    = true,
                Rtncode = FaultInfoRcConstants.OK,
                RtnMsg  = "OK"
            };

            _appListItem.AppOSID = "22";
            _appListService.DeleteAppOs(Arg.Any <string>()).Returns(true);

            //Act
            TResult <bool> actualResponse = _targetObj.DeleteApp(_appListItem);

            //Assert
            Assert.AreEqual(expectedResponse.data, actualResponse.data);
            Assert.AreEqual(expectedResponse.Rtncode, actualResponse.Rtncode);
            Assert.AreEqual(expectedResponse.RtnMsg, actualResponse.RtnMsg);

            //驗證 至少這個 DeleteApp 被調用一次過 而另一個沒有被調用
            _appListService.Received(0).DeleteApp(Arg.Any <string>());
            _appListService.Received(1).DeleteAppOs(Arg.Any <string>());
        }
Esempio n. 2
0
        /// <summary>
        /// 如果資料 只新增 AppList 需刪除 AppID 就可
        /// 如果資料 新增到 AppOS 需刪除 AppOSID
        /// </summary>
        /// <param name="appListItem"></param>
        /// <returns></returns>
        public TResult <bool> DeleteApp(AppListItem appListItem)
        {
            bool deleted = false;

            if (!string.IsNullOrEmpty(appListItem.AppOSID))
            {
                //有值 代表需刪除  AppOS 就可以
                deleted = _appListService.DeleteAppOs(appListItem.AppOSID);
            }
            else
            {
                //無值 代表 只新增 AppList 階段 需刪除 AppID 就可
                deleted = _appListService.DeleteApp(appListItem.AppID);
            }
            if (deleted)
            {
                return(TResult <bool> .OK(true, "OK"));
            }
            else
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "delete fail!"));
            }
        }
 public void Test_DeleteAppOs()
 {
     _targetObj.DeleteAppOs("");
 }