예제 #1
0
        public void Test_the_return_type_of_the_GetRequestStatus_to_be_listType_when_norequest_is_returned_from_the_database()
        {
            //arrange
            List <Assets>   assetList   = new List <Assets>();
            List <Requests> requestList = new List <Requests>();
            AssetDetails    asset       = new AssetDetails();

            assetList.Add(new Assets()
            {
                ReassignedTo = "00000069", AssetCode = "0000345630"
            });
            EmployeeDetails emp = new EmployeeDetails()
            {
                EmployeeCode = "00059644", EmployeeName = "Monika"
            };
            var mockReq         = new Mock <IRequestDetailsRepo>();
            var mockAssetRepo   = new Mock <IAssetDetailsRepo>();
            var mockAssetDbRepo = new Mock <IAssetDbRepo>();
            var mockEmpDbRepo   = new Mock <IEmployeeDbRepo>();

            mockEmpDbRepo.Setup(x => x.GetName(It.IsAny <string>())).Returns(emp);
            mockReq.Setup(x => x.GetAllRequest()).Returns(requestList);
            mockAssetRepo.Setup(x => x.GetAssetByEmpCode(It.IsAny <string>())).Returns(assetList);
            mockAssetDbRepo.Setup(x => x.GetAssetByCode(It.IsAny <string>())).Returns(asset);
            AssetControllerService obj = new AssetControllerService(mockAssetRepo.Object, mockReq.Object, mockAssetDbRepo.Object, mockEmpDbRepo.Object);

            //act
            var result = obj.GetRequestStatus();

            //Assert
            Assert.IsType <List <AssetDetails> >(result);
            Assert.Empty(result);
        }
예제 #2
0
        public void Test_the_return_type_of_the_GetRequestStatus_to_be_listType()
        {
            //arrange
            List <Assets>   assetList   = new List <Assets>();
            AssetDetails    asset       = new AssetDetails();
            List <Requests> requestList = new List <Requests>();
            EmployeeDetails emp         = new EmployeeDetails()
            {
                EmployeeCode = "00059644", EmployeeName = "Monika"
            };

            requestList.Add(new Requests()
            {
                RequestId = 1, EmployeeCode = "00000068", RequestStatus = RequestStatus.Completed, PendingWith = PendingWith.Approved, DateOfCompletionRequest = DateTime.Parse("10/8/2017"), NewPsaCode = "1", NewOuCode = "1", NewPaCode = "1", NewCcCode = "1"
            });
            assetList.Add(new Assets()
            {
                ReassignedTo = "00000069", AssetCode = "0000345630"
            });
            var mockReq         = new Mock <IRequestDetailsRepo>();
            var mockAssetRepo   = new Mock <IAssetDetailsRepo>();
            var mockAssetDbRepo = new Mock <IAssetDbRepo>();
            var mockEmpDbRepo   = new Mock <IEmployeeDbRepo>();

            mockEmpDbRepo.Setup(x => x.GetName(It.IsAny <string>())).Returns(emp);
            mockReq.Setup(x => x.GetAllRequest()).Returns(requestList);
            mockAssetRepo.Setup(x => x.GetAssetByEmpCode(It.IsAny <string>())).Returns(assetList);
            mockAssetDbRepo.Setup(x => x.GetAssetByCode(It.IsAny <string>())).Returns(asset);
            AssetControllerService obj = new AssetControllerService(mockAssetRepo.Object, mockReq.Object, mockAssetDbRepo.Object, mockEmpDbRepo.Object);

            //act
            var result = obj.GetRequestStatus();

            //Assert
            Assert.IsType <List <AssetDetails> >(result);
            Assert.NotNull(result);
        }