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

            _appListItem.AppOSID = null;
            _appListService.DeleteApp(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(1).DeleteApp(Arg.Any <string>());
            _appListService.Received(0).DeleteAppOs(Arg.Any <string>());
        }
        public void Check_Has_AppUserGroup_Insert_To_WisAppUserList()
        {
            //Arrange
            TResult <ResponseAppNameCreate> expectedResponse = new TResult <ResponseAppNameCreate>
            {
                Data = new ResponseAppNameCreate
                {
                    IsSuccessful = true,
                    AppID        = "4beedc78-0d31-496e-bb9c-81a79c9c6bc6"
                },
                Rtncode = FaultInfoRcConstants.OK,
                RtnMsg  = "Test AppName"
            };

            _request.IsTop        = false;
            _request.AppUserGroup = "1,2";

            _appListService.AppNameIsExisted(_request.AppName).Returns(false);
            _appListService.GetIsTopAppList().Returns(_inSideOrOutSideApp);

            _appListService.GetDefineGroup(Arg.Any <List <string> >()).Returns(_wisDefineGroups);
            _appListService.InsertAppName(Arg.Any <WisAppList>(), Arg.Any <List <WisAppUserList> >()).Returns(true);
            _appListService.GetHrEmpByLocation(Arg.Any <List <string> >()).Returns(new List <MdsHrEmpData>());
            _appListService.GetHrEmpByUId(Arg.Any <List <string> >()).Returns(new List <MdsHrEmpData>());
            _appListService.GetMdsAdUser(Arg.Any <List <string> >()).Returns(new List <MdsAdUserData>());

            //Act
            TResult <ResponseAppNameCreate> actualResponse = _targetObj.InsertAppName(_request);

            //Assert
            Assert.AreEqual(expectedResponse.Rtncode, actualResponse.Rtncode);
            Assert.AreEqual(expectedResponse.RtnMsg, actualResponse.RtnMsg);
            Assert.AreEqual(expectedResponse.Data.IsSuccessful, actualResponse.Data.IsSuccessful);
            _appListService.Received(1).GetHrEmpByLocation(Arg.Any <List <string> >());
            _appListService.Received(1).GetHrEmpByUId(Arg.Any <List <string> >());
            _appListService.Received(1).GetMdsAdUser(Arg.Any <List <string> >());
        }