/// <summary> /// 啟用/停用 APP /// </summary> /// <returns></returns> public TResult <bool> EnableOrDisableApp(AppListItem appListItem) { //UI 畫面 是啟用 就是 反向 string status = appListItem.Status ? AppStatus.Disable : AppStatus.Enable; if (status == AppStatus.Enable && !string.IsNullOrEmpty(appListItem.OSType)) { //先檢查 有無其他版本啟用 不包含自己 WisAppOs wisAppOs = _appListService.CheckAppOsStatus(appListItem.AppID, appListItem.OSType == "IOS" ? 1 : 2); if (wisAppOs != null && wisAppOs.AppOSID != Convert.ToInt32(appListItem.AppOSID)) { return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "已有其本版已啟用!")); } } bool updated = _appListService.EnableOrDisableApp(appListItem.AppOSID, status); if (updated) { return(TResult <bool> .OK(true, "OK")); } else { return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "updated fail!")); } }
public void Enable_Or_DisableApp_Is_Updated() { //Arrage TResult <bool> expectedResponse = new TResult <bool> { data = true, Rtncode = FaultInfoRcConstants.OK, RtnMsg = "OK" }; _appListService.CheckAppOsStatus(Arg.Any <string>(), Arg.Any <int>()).Returns(_alreadyEnabled); _appListService.EnableOrDisableApp(Arg.Any <string>(), Arg.Any <string>()).Returns(true); //Act TResult <bool> actualResponse = _targetObj.EnableOrDisableApp(_appListItem); //Assert Assert.AreEqual(expectedResponse.data, actualResponse.data); Assert.AreEqual(expectedResponse.Rtncode, actualResponse.Rtncode); Assert.AreEqual(expectedResponse.RtnMsg, actualResponse.RtnMsg); }
public void Test_EnableOrDisableApp() { _targetObj.EnableOrDisableApp("", ""); }