コード例 #1
0
        public void ReconciliationMethodOfProductionTest()
        {
            #region Data
            WBS_Deliverables wbs_deliverable = new WBS_Deliverables()
            {
                DeliverableId  = 14000023,
                FullWBSNumber  = "1147614.001.001",
                MasterVendorId = 1
            };
            List <WBS_Deliverables> wbs_deliverables = new List <WBS_Deliverables>();
            wbs_deliverables.Add(wbs_deliverable);
            wbs_deliverables.Add(new WBS_Deliverables {
                FullWBSNumber = "1147614.003.001", DeliverableId = 14000000, MasterVendorId = 2, ProductionMethodTypeId = 5
            });
            wbs_deliverables.Add(new WBS_Deliverables {
                FullWBSNumber = "1147614.022.001", DeliverableId = 14000012, MasterVendorId = 2, ProductionMethodTypeId = 6
            });
            wbs_deliverables.Add(new WBS_Deliverables {
                FullWBSNumber = "1147614.022.001", DeliverableId = 14000032, MasterVendorId = 2, ProductionMethodTypeId = 4
            });

            #endregion

            #region Mock
            mockfinanceservice.Setup(x => x.ReconciliationMethodOfProduction(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(wbs_deliverables);
            mockWBS_DeliverablesRepository.Setup(x => x.ReconciliationMethodOfProduction(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(wbs_deliverables);
            //Finance Service Mock
            var financeservicemock = new FinanceServiceMock(_iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var FinanceController = new FinanceControllerMock(financeServicee: mockFinanceService.Object);
            #endregion

            #region service
            List <WBS_Deliverables> result = financeservicemock.ReconciliationMethodOfProduction(wbs_deliverable.DeliverableId, wbs_deliverable.MasterVendorId ?? default(int), wbs_deliverable.FullWBSNumber);
            #endregion

            #region Assertions
            mockWBS_DeliverablesRepository.Verify();
            Assert.IsFalse(result == null);
            Assert.IsTrue(result.Count > 0);
            Assert.IsTrue(result.ElementAt(1).MasterVendorId == 2);
            Assert.IsTrue(result.ElementAt(2).ProductionMethodTypeId == 6);
            #endregion
        }
コード例 #2
0
        public void CreateBatch_ShouldReturnSuccessTest()
        {
            #region Data
            int        mrmUserId  = 25;
            List <int> channelist = new List <int>()
            {
                1, 2, 3
            };
            List <int> budgettypelist = new List <int>()
            {
                1, 2
            };

            SqlParameter userChannels = new SqlParameter("@ChannelIds", SqlDbType.NVarChar);
            userChannels.Value = channelist;

            SqlParameter userBudgetTypes = new SqlParameter("@BudgetTypeID", SqlDbType.NVarChar);
            userBudgetTypes.Value = budgettypelist;

            SqlParameter userId = new SqlParameter("@UserID", SqlDbType.Int);
            userId.Value = mrmUserId;

            SqlParameter invoiceHeaderId = new SqlParameter("@InvoiceHeaderId", SqlDbType.Int);
            invoiceHeaderId.Value = 119;

            List <SqlParameter> result = new List <SqlParameter>();
            result.Add(userChannels);
            result.Add(userBudgetTypes);
            result.Add(userId);
            result.Add(invoiceHeaderId);

            ApUploadUserChoiceModel apUploadUserChoiceModel = new ApUploadUserChoiceModel()
            {
                UserId = mrmUserId,
                UserSelectedChannelList    = channelist,
                UserSelectedBudgetTypeList = budgettypelist
            };
            UserMessageModel usermodel = new UserMessageModel();
            MRM.DANG.Model.UserMessageModel userMessage_SuccessCase = new Model.UserMessageModel
            {
                StatusNumber = 0,
                IsSuccess    = true,
                Message      = "Batch Created Succesfuly"
            };
            #endregion

            #region  Mock
            mockApInvoiceBatchRepository.Setup(x => x.CreateBatch(It.IsAny <ApUploadUserChoiceModel>()))
            .Returns(userMessage_SuccessCase);

            #endregion

            #region Service
            var financeService = new FinanceServiceMock(
                apInvoiceBatchRepository: mockApInvoiceBatchRepository.Object);
            UserMessageModel userMessage = financeService.CreateBatch(apUploadUserChoiceModel);
            #endregion

            #region Assertions
            Assert.IsFalse(userMessage.Message == "No approved invoices exist for the for selected channels and budget type.");
            Assert.IsTrue(userMessage.Message == "Batch Created successfully.");
            Assert.IsTrue(userMessage.StatusNumber == 0);
            Assert.IsTrue(userMessage.IsSuccess == true);
            #endregion
        }
コード例 #3
0
        public void CreateBatch_ShouldReturnErrorTest()
        {
            #region Data
            int        mrmUserId  = 25;
            List <int> channelist = new List <int>()
            {
                1, 2, 3
            };
            List <int> budgettypelist = new List <int>()
            {
                1, 2
            };

            SqlParameter userChannels = new SqlParameter("@ChannelIds", SqlDbType.NVarChar);
            userChannels.Value = channelist;

            SqlParameter userBudgetTypes = new SqlParameter("@BudgetTypeID", SqlDbType.NVarChar);
            userBudgetTypes.Value = budgettypelist;

            SqlParameter userId = new SqlParameter("@UserID", SqlDbType.Int);
            userId.Value = mrmUserId;

            SqlParameter invoiceHeaderId = new SqlParameter("@InvoiceHeaderId", SqlDbType.Int);
            invoiceHeaderId.Value = 119;

            List <SqlParameter> result = new List <SqlParameter>();
            result.Add(userChannels);
            result.Add(userBudgetTypes);
            result.Add(userId);
            result.Add(invoiceHeaderId);

            ApUploadUserChoiceModel apUploadUserChoiceModel = new ApUploadUserChoiceModel()
            {
                UserId = mrmUserId,
            };
            MRM.DANG.Model.UserMessageModel userMessage_Error = new Model.UserMessageModel
            {
                IsSuccess = false,
                IsWarning = false
            };

            bool             exceptionCaught = false;
            UserMessageModel userMessage     = new UserMessageModel();
            #endregion

            #region  Mock
            mockApInvoiceBatchRepository.Setup(x => x.CreateBatch(It.IsAny <ApUploadUserChoiceModel>()))
            .Returns(userMessage_Error);
            #endregion

            #region Service
            var financeService = new FinanceServiceMock(
                apInvoiceBatchRepository: mockApInvoiceBatchRepository.Object);
            try
            {
                userMessage = financeService.CreateBatch(It.IsAny <ApUploadUserChoiceModel>());
            }
            catch (Exception ex)
            {
                exceptionCaught = true;
            }

            #endregion

            #region Assertions
            Assert.IsFalse(userMessage.IsSuccess == true);
            Assert.IsTrue(userMessage.IsWarning == false);
            Assert.IsTrue(exceptionCaught == true);
            #endregion
        }
コード例 #4
0
        public void AddUpdateInvoice_Test()
        {
            #region Data
            int              mrmUserId    = 1;
            string           networkLogin = "******";
            InvoiceViewModel viewModel    = new InvoiceViewModel()
            {
                Id            = 0,
                Vendor        = 142,
                PaymentTerm   = 9,
                Status        = 2,
                InvoiceNumber = "123",
                InvoiceDate   = DateTime.Now,
                PostingDate   = DateTime.Now,
                Comments      = "Invoice Creation Comments",
                WebUser       = 123,//mrmuserId,
                timestamp     = null
            };
            List <InvoiceLineViewModel> lstInvoiceLines = new List <InvoiceLineViewModel>();
            InvoiceLineViewModel        invoiceLine1    = new InvoiceLineViewModel()
            {
                ContractNumber      = "1234",
                PurchaseOrderNumber = "Abcd1234",
                Description         = "Test InvoiceLine1 to insert",
                Comment             = "Test Comment to insert",
                Amount = 250,
                DeliverableBudgetId = 129289,
                GLAccountId         = 50,
                Id = 1,
                ProductionMethodType = 2,
                WBSElementId         = 3250,
                WBSNumber            = "1146",
                Coding = "",
                ChannelCostCenterId   = 21,
                ChannelProfitCenterId = null,
            };
            InvoiceLineViewModel invoiceLine2 = new InvoiceLineViewModel()
            {
                ContractNumber      = "2345",
                PurchaseOrderNumber = "Abcd2345",
                Description         = "Test InvoiceLine2 to insert",
                Comment             = "Test Comment to insert",
                Amount = 124,
                DeliverableBudgetId = 13458,
                GLAccountId         = 50,
                Id = 1,
                ProductionMethodType = 1,
                WBSElementId         = 3250,
                WBSNumber            = "1146",
                Coding = "",
                ChannelCostCenterId   = null,
                ChannelProfitCenterId = 21
            };
            Vendor vendor = new Vendor()
            {
                Name = "TestVendor1",
                Id   = 1,
            };
            InvoiceStatus status = new InvoiceStatus()
            {
                Id   = 1,
                Name = "In Progress"
            };

            lstInvoiceLines.Add(invoiceLine1);
            lstInvoiceLines.Add(invoiceLine2);
            viewModel.InvoiceLines = lstInvoiceLines;
            InvoiceHeader theInvoice = FinanceMapper.ToInvoice(viewModel);
            theInvoice.Vendor        = vendor;
            theInvoice.InvoiceStatus = status;
            InvoiceHeader theInvoice1 = FinanceMapper.ToInvoice(viewModel);
            theInvoice1.Id = 999;
            #endregion

            #region  Mock
            //invoiceHeaderRepository  Mock
            mockInvoiceHeaderRepository.Setup(x => x.Add(It.IsAny <InvoiceHeader>())).Returns(theInvoice);
            //iunit Mock
            mockIUnitOfWork.Setup(x => x.Commit());
            //IInvoiceLine Repository Mock
            mockIInvoiceLineRepository.Setup(x => x.Add(It.IsAny <InvoiceLine>())).Returns(() => null);
            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.AddInvoice(It.IsAny <InvoiceHeader>())).Returns(theInvoice);
            mockFinanceService.Setup(x => x.GetInvoiceById(It.IsAny <int>())).Returns(theInvoice);
            this.mockInvoiceHeaderRepository.Setup(x => x.GetById(It.IsAny <long>())).Returns(theInvoice);
            this.mockInvoiceHeaderRepository.Setup(x => x.GetById(It.IsAny <long>())).Returns(theInvoice1);
            mockInvoiceHeaderRepository.Setup(x => x.GetInvoiceById(It.IsAny <int>())).Returns(theInvoice);
            mockIInvoiceLineRepository.Setup(x => x.GetMany(It.IsAny <Expression <Func <InvoiceLine, bool> > >()))
            .Returns(new List <InvoiceLine>());
            mockIInvoiceLineRepository.Setup(x => x.GetById(It.IsAny <long>()))
            .Returns(new InvoiceLine());
            mockInvoiceHeaderRepository.Setup(x => x.Update(It.IsAny <InvoiceHeader>()));
            mockIInvoiceLineRepository.Setup(x => x.Update(It.IsAny <InvoiceLine>()));
            //mock to finance Service
            FinanceServiceMock financeService = new FinanceServiceMock(
                invoiceHeaderRepository: mockInvoiceHeaderRepository.Object, unitOfWork: mockIUnitOfWork.Object, invoiceLineRepository: mockIInvoiceLineRepository.Object);

            //Finance Controller Mock
            var FinanceController = new FinanceControllerMock(financeServicee: financeService);
            #endregion

            #region Assertions
            mockInvoiceHeaderRepository.Verify();
            mockIUnitOfWork.Verify();
            mockIInvoiceLineRepository.Verify();
            mockFinanceService.Verify();

            //Mapping the viewmodel to actual Table
            var serviceResult = financeService.AddInvoice(theInvoice);
            Assert.IsNotNull(serviceResult);
            Assert.IsNotNull(serviceResult.InvoiceLine);
            Assert.AreEqual(serviceResult.Id, 0);//The actual Id is auto generated after insertion done in DB.
            //As we are passing 0 as invoice headerId for the purpose of insertion here we recieve the same.

            var controllerResult = FinanceController.AddUpdateInvoice(viewModel, mrmUserId, networkLogin);
            Assert.IsNotNull(controllerResult);
            Assert.AreEqual(controllerResult.Success, true);
            Assert.IsNotNull(controllerResult.Data);

            //Service N Controller Assertions for Updating Invoice
            viewModel.Id = 999;

            //Mapping the viewmodel to actual Table
            var serviceResultForUpdate = financeService.UpdateInvoice(theInvoice1);
            Assert.IsNotNull(serviceResultForUpdate);
            Assert.IsNotNull(serviceResultForUpdate.InvoiceLine);
            Assert.AreEqual(serviceResultForUpdate.Id, 999);//Here we will recieve the same invoice header id we passed for update

            var controllerUpdateResult = FinanceController.AddUpdateInvoice(viewModel, mrmUserId, networkLogin);
            Assert.IsNotNull(controllerUpdateResult);
            Assert.AreEqual(controllerUpdateResult.Success, true);
            Assert.IsNotNull(controllerUpdateResult.Data);
            #endregion
        }
コード例 #5
0
        public void GetDeliverableByWbs_Test()
        {
            //Set Data
            List <DropDownViewModel> lstdropDownViewModel = new List <DropDownViewModel>();
            DropDownViewModel        drpDownModel         = new DropDownViewModel()
            {
            };
            List <WBS_Deliverables> lstWBS = new List <WBS_Deliverables>();
            WBS_Deliverables        wbs1   = new WBS_Deliverables()
            {
                WBSElementId        = 17,
                FullWBSNumber       = "11234.001.002",
                DeliverableId       = 1,
                DeliverableName     = "Deliverable1",
                SAPVendorId         = 68,
                DeliverableBudgetId = 123567
            };
            WBS_Deliverables wbs2 = new WBS_Deliverables()
            {
                WBSElementId             = 21,
                FullWBSNumber            = "12456.001.002",
                ProductionMethodTypeId   = 2,
                ProductionMethodTypeName = "Contract Request",
                DeliverableId            = 2,
                DeliverableName          = "Deliverable2",
                SAPVendorId         = 72,
                DeliverableBudgetId = 123586
            };
            WBS_Deliverables wbs3 = new WBS_Deliverables()
            {
                TypeOfWorkId             = 3456,
                WBSElementId             = 31,
                FullWBSNumber            = "11234.003.001",
                ProductionMethodTypeId   = 3,
                ProductionMethodTypeName = "Miscellaneous",
                DeliverableId            = 3,
                DeliverableName          = "Deliverable3",
                SAPVendorId         = 74,
                DeliverableBudgetId = 123521
            };

            lstWBS.Add(wbs1);
            lstWBS.Add(wbs2);
            lstWBS.Add(wbs3);

            DropDownViewModel vm1 = new DropDownViewModel()
            {
                Text        = "Deliverable1",
                Value       = "1",
                Id          = 1,
                Description = "1" + "|" + "11234.001.002" + "|" + "Deliverable1" + "|" + "123567"
            };
            DropDownViewModel vm2 = new DropDownViewModel()
            {
                Text        = "Deliverable2",
                Value       = "2",
                Id          = 2,
                Description = "2" + "|" + "12456.001.002" + "|" + "Deliverable2" + "|" + "123586"
            };
            DropDownViewModel vm3 = new DropDownViewModel()
            {
                Text        = "Deliverable3",
                Value       = "3",
                Id          = 3,
                Description = "3" + "|" + "11234.003.001" + "|" + "Deliverable3" + "|" + "123521"
            };

            lstdropDownViewModel.Add(vm1);
            lstdropDownViewModel.Add(vm2);
            lstdropDownViewModel.Add(vm3);

            //Inputs
            bool   isExternal   = false;
            string filter       = "";
            int    mrmUserid    = 1234;
            string networkLogin = "******";
            int    wbsId        = 31;
            int    SAPVendorId  = 74;

            #region Mock
            //Mock

            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.GetDeliverableByWbs(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);
            //iWBS_DeliverablesRepository Mock
            mockWBS_DeliverablesRepository.Setup(x => x.GetDeliverableByWbs(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);


            var financeService = new FinanceServiceMock(
                _iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var DropDownController = new DropDownControllerMock(financeService: mockFinanceService.Object);

            #endregion

            //Assertions
            mockFinanceService.Verify();
            mockWBS_DeliverablesRepository.Verify();

            var serviceResult = financeService.GetDeliverableByWbs(wbsId, SAPVendorId, isExternal);


            #region "Assertion of GetWBSByTow"
            Assert.IsNotNull(serviceResult);         //Result is not Null
            Assert.AreEqual(serviceResult, lstWBS);  //Asserting the expected return object with dummy data
            Assert.AreEqual(serviceResult.Count, 3); //Assert matching the return data with my input

            var controllerResult = DropDownController.GetDeliverableByWbs(isExternal, wbsId, SAPVendorId, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult);//Result is not Null
            Assert.AreEqual(controllerResult.Count, 3);
            Assert.AreEqual(controllerResult[0].Text, "1( Deliverable1 )");
            Assert.AreEqual(controllerResult[0].Description, "1|11234.001.002|Deliverable1|123567");

            SAPVendorId = 17;
            wbsId       = 68;
            var controllerResult1 = DropDownController.GetDeliverableByWbs(isExternal, wbsId, SAPVendorId, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult1);//Result is not Null
            Assert.AreEqual(controllerResult1[1].Text, "2( Deliverable2 )");
            Assert.AreEqual(controllerResult1[1].Description, "2|12456.001.002|Deliverable2|123586");
            #endregion
        }
コード例 #6
0
        public void GetDeliverableNameByMopNWBS_Test()
        {
            //Set Data
            List <DropDownViewModel> lstdropDownViewModel = new List <DropDownViewModel>();
            DropDownViewModel        drpDownModel         = new DropDownViewModel()
            {
            };
            List <WBS_Deliverables> lstWBS = new List <WBS_Deliverables>();
            WBS_Deliverables        wbs1   = new WBS_Deliverables()
            {
                TypeOfWorkId             = 542,
                WBSElementId             = 17,
                FullWBSNumber            = "11234.001.002",
                ProductionMethodTypeId   = 1,
                ProductionMethodTypeName = "Post House",
                DeliverableId            = 1,
                DeliverableName          = "Deliverable1"
            };
            WBS_Deliverables wbs2 = new WBS_Deliverables()
            {
                TypeOfWorkId             = 2345,
                WBSElementId             = 21,
                FullWBSNumber            = "12456.001.002",
                ProductionMethodTypeId   = 2,
                ProductionMethodTypeName = "Contract Request",
                DeliverableId            = 2,
                DeliverableName          = "Deliverable2"
            };
            WBS_Deliverables wbs3 = new WBS_Deliverables()
            {
                TypeOfWorkId             = 3456,
                WBSElementId             = 31,
                FullWBSNumber            = "11234.003.001",
                ProductionMethodTypeId   = 3,
                ProductionMethodTypeName = "Miscellaneous",
                DeliverableId            = 3,
                DeliverableName          = "Deliverable3"
            };

            lstWBS.Add(wbs1);
            lstWBS.Add(wbs2);
            lstWBS.Add(wbs3);

            DropDownViewModel vm1 = new DropDownViewModel()
            {
                Text  = "Deliverable1",
                Value = "1",
                Id    = 1
            };
            DropDownViewModel vm2 = new DropDownViewModel()
            {
                Text  = "Deliverable2",
                Value = "2",
                Id    = 2
            };
            DropDownViewModel vm3 = new DropDownViewModel()
            {
                Text  = "Deliverable3",
                Value = "3",
                Id    = 3
            };

            lstdropDownViewModel.Add(vm1);
            lstdropDownViewModel.Add(vm2);
            lstdropDownViewModel.Add(vm3);

            //Inputs
            bool   isExternal   = false;
            string filter       = "";
            int    mrmUserid    = 1234;
            string networkLogin = "******";
            int    wbsId        = 31;
            int    mopId        = 1;

            #region Mock
            //Mock

            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.GetDeliverableNameByMopNWBS(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);
            //iWBS_DeliverablesRepository Mock
            mockWBS_DeliverablesRepository.Setup(x => x.GetDeliverableNameByMopNWBS(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);


            var financeService = new FinanceServiceMock(
                _iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var DropDownController = new DropDownControllerMock(financeService: mockFinanceService.Object);

            #endregion

            //Assertions
            mockFinanceService.Verify();
            mockWBS_DeliverablesRepository.Verify();

            var serviceResult = financeService.GetDeliverableNameByMopNWBS(wbsId, mopId, isExternal);


            #region "Assertion of GetWBSByTow"
            Assert.IsNotNull(serviceResult);         //Result is not Null
            Assert.AreEqual(serviceResult, lstWBS);  //Asserting the expected return object with dummy data
            Assert.AreEqual(serviceResult.Count, 3); //Assert matching the return data with my input

            var controllerResult = DropDownController.GetDeliverableNameByMopNWBS(wbsId, mopId, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult);//Result is not Null
            Assert.AreEqual(controllerResult.Count, 3);
            Assert.AreEqual(controllerResult[0].Text, "Deliverable1");

            filter = "Deliverable2";
            var controllerResultForFilter = DropDownController.GetDeliverableNameByMopNWBS(wbsId, mopId, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForFilter);//Result is not Null
            Assert.AreSame(controllerResultForFilter[0].Text.Trim(), "Deliverable2");
            #endregion
        }
コード例 #7
0
        public void GetDeliverableForInvoice_Test()
        {
            //Set Data
            List <DropDownViewModel> lstdropDownViewModel = new List <DropDownViewModel>();
            DropDownViewModel        drpDownModel         = new DropDownViewModel()
            {
            };
            List <WBS_Deliverables> lstWBS = new List <WBS_Deliverables>();
            WBS_Deliverables        wbs1   = new WBS_Deliverables()
            {
                DeliverableId   = 1234,
                DeliverableName = "Deliverable1",
                ExternalWBSFlag = false
            };
            WBS_Deliverables wbs2 = new WBS_Deliverables()
            {
                DeliverableId   = 2345,
                DeliverableName = "Deliverable2",
                ExternalWBSFlag = true
            };
            WBS_Deliverables wbs3 = new WBS_Deliverables()
            {
                DeliverableId   = 3456,
                DeliverableName = "Deliverable3",
                ExternalWBSFlag = false
            };

            lstWBS.Add(wbs1);
            lstWBS.Add(wbs2);
            lstWBS.Add(wbs3);

            DropDownViewModel vm1 = new DropDownViewModel()
            {
                Text  = "1234 ( Deliverable1 )",
                Value = "1234"
            };
            DropDownViewModel vm2 = new DropDownViewModel()
            {
                Text  = "2345 ( Deliverable2 )",
                Value = "2345"
            };
            DropDownViewModel vm3 = new DropDownViewModel()
            {
                Text  = "3456 ( ExternalDeliverable )",
                Value = "3456"
            };

            lstdropDownViewModel.Add(vm1);
            lstdropDownViewModel.Add(vm2);
            lstdropDownViewModel.Add(vm3);

            //Inputs
            bool   isExternal   = false;
            string filter       = "";
            int    mrmUserid    = 1234;
            string networkLogin = "******";

            //Mock

            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.GetDeliverablesForInvoiceLine(It.IsAny <bool>())).Returns(lstWBS);
            //iWBS_DeliverablesRepository Mock
            mockWBS_DeliverablesRepository.Setup(x => x.GetDeliverablesForInvoiceLine(It.IsAny <bool>())).Returns(lstWBS);

            var financeService = new FinanceServiceMock(_iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var DropDownController = new DropDownControllerMock(financeService: mockFinanceService.Object);


            //Assertions
            mockFinanceService.Verify();
            mockWBS_DeliverablesRepository.Verify();

            var serviceResult = financeService.GetDeliverablesForInvoiceLine(isExternal);


            #region "Assertion ofGetDeliverableForInvoice"
            Assert.IsNotNull(serviceResult);         //Result is not Null
            Assert.AreEqual(serviceResult, lstWBS);  //Asserting the expected return object with dummy data
            Assert.AreEqual(serviceResult.Count, 3); //Assert matching the return data with my input

            var controllerResult = DropDownController.GetDeliverableForInvoice(isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult);//Result is not Null
            Assert.AreEqual(controllerResult.Count, 3);

            isExternal = true;
            var controllerResultForExternalTrue = DropDownController.GetDeliverableForInvoice(isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForExternalTrue);//Result is not Null
            Assert.AreEqual(controllerResultForExternalTrue.Count, 3);

            filter = "Deliverable1";
            var controllerResultForfiltereingonDeliverableText = DropDownController.GetDeliverableForInvoice(isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForfiltereingonDeliverableText);//Result is not Null
            Assert.AreEqual(controllerResultForfiltereingonDeliverableText.Count, 1);

            #endregion
        }
コード例 #8
0
        public void GetWBSByDeliverableNMOP_Test()
        {
            //Set Data
            List <DropDownViewModel> lstdropDownViewModel = new List <DropDownViewModel>();
            DropDownViewModel        drpDownModel         = new DropDownViewModel()
            {
            };
            List <WBS_Deliverables> lstWBS = new List <WBS_Deliverables>();
            WBS_Deliverables        wbs1   = new WBS_Deliverables()
            {
                DeliverableId   = 1234,
                WBSElementId    = 1,
                DeliverableName = "Deliverable1",
                FullWBSNumber   = "11234.001.002"
            };
            WBS_Deliverables wbs2 = new WBS_Deliverables()
            {
                DeliverableId   = 2345,
                WBSElementId    = 2,
                FullWBSNumber   = "12456.001.002",
                DeliverableName = "Deliverable2",
            };
            WBS_Deliverables wbs3 = new WBS_Deliverables()
            {
                DeliverableId   = 3456,
                WBSElementId    = 3,
                FullWBSNumber   = "11234.003.001",
                DeliverableName = "Deliverable1",
            };

            lstWBS.Add(wbs1);
            lstWBS.Add(wbs2);
            lstWBS.Add(wbs3);

            DropDownViewModel vm1 = new DropDownViewModel()
            {
                Text  = "11234.001.002",
                Value = "1"
            };
            DropDownViewModel vm2 = new DropDownViewModel()
            {
                Text  = "12456.001.002",
                Value = "2"
            };
            DropDownViewModel vm3 = new DropDownViewModel()
            {
                Text  = "11234.003.001",
                Value = "3"
            };

            lstdropDownViewModel.Add(vm1);
            lstdropDownViewModel.Add(vm2);
            lstdropDownViewModel.Add(vm3);

            //Inputs
            bool   isExternal    = false;
            string filter        = "";
            int    mrmUserid     = 1234;
            string networkLogin  = "******";
            int    deliverableId = 1234;
            int    mopId         = 542;

            #region Mock
            //Mock

            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.GetWBSByDeliverableNMOP(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);
            //iWBS_DeliverablesRepository Mock
            mockWBS_DeliverablesRepository.Setup(x => x.GetWBSByDeliverableNMOP(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);


            var financeService = new FinanceServiceMock(
                _iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var DropDownController = new DropDownControllerMock(financeService: mockFinanceService.Object);

            #endregion

            //Assertions
            mockFinanceService.Verify();
            mockWBS_DeliverablesRepository.Verify();

            var serviceResult = financeService.GetWBSByDeliverableNMOP(deliverableId, mopId, isExternal);


            #region "Assertion of GetWBSByDeliverableNMOP"
            Assert.IsNotNull(serviceResult);         //Result is not Null
            Assert.AreEqual(serviceResult, lstWBS);  //Asserting the expected return object with dummy data
            Assert.AreEqual(serviceResult.Count, 3); //Assert matching the return data with my input

            var controllerResult = DropDownController.GetWBSByDeliverableNMOP(deliverableId, mopId, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult);//Result is not Null
            Assert.AreEqual(controllerResult.Count, 3);

            isExternal = true;
            var controllerResultForExternalTrue = DropDownController.GetWBSByDeliverableNMOP(deliverableId, mopId, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForExternalTrue);//Result is not Null
            Assert.AreSame(controllerResultForExternalTrue[2].Text.Trim(), "11234.003.001");

            filter = "Deliverable1";
            var controllerResultForFilter = DropDownController.GetWBSByDeliverableNMOP(deliverableId, mopId, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForExternalTrue);//Result is not Null
            Assert.AreSame(controllerResultForExternalTrue[0].Text.Trim(), "11234.001.002");
            #endregion
        }
コード例 #9
0
        public void GetMethodOFProductionByDeliverableId_Test()
        {
            //Set Data
            List <DropDownViewModel> lstdropDownViewModel = new List <DropDownViewModel>();
            DropDownViewModel        drpDownModel         = new DropDownViewModel()
            {
            };
            List <WBS_Deliverables> lstWBS = new List <WBS_Deliverables>();
            WBS_Deliverables        wbs1   = new WBS_Deliverables()
            {
                DeliverableId            = 1234,
                ExternalWBSFlag          = false,
                ProductionMethodTypeId   = 1,
                ProductionMethodTypeName = "Post House",
                DeliverableName          = "Deliverable1"
            };
            WBS_Deliverables wbs2 = new WBS_Deliverables()
            {
                DeliverableId            = 2345,
                DeliverableName          = "Deliverable2",
                ExternalWBSFlag          = true,
                ProductionMethodTypeId   = 2,
                ProductionMethodTypeName = "Contract Request"
            };
            WBS_Deliverables wbs3 = new WBS_Deliverables()
            {
                DeliverableId            = 3456,
                DeliverableName          = "Deliverable3",
                ExternalWBSFlag          = false,
                ProductionMethodTypeId   = 3,
                ProductionMethodTypeName = "Miscellaneous"
            };

            lstWBS.Add(wbs1);
            lstWBS.Add(wbs2);
            lstWBS.Add(wbs3);

            DropDownViewModel vm1 = new DropDownViewModel()
            {
                Text  = "Post House",
                Value = "1"
            };
            DropDownViewModel vm2 = new DropDownViewModel()
            {
                Text  = "Contract Request",
                Value = "2"
            };
            DropDownViewModel vm3 = new DropDownViewModel()
            {
                Text  = "Miscellaneous",
                Value = "3"
            };

            lstdropDownViewModel.Add(vm1);
            lstdropDownViewModel.Add(vm2);
            lstdropDownViewModel.Add(vm3);

            //Inputs
            bool   isExternal    = false;
            string filter        = "";
            int    mrmUserid     = 1234;
            string networkLogin  = "******";
            int    deliverableId = 1234;
            int    vendorid      = 23;
            int    wbsid         = 212;

            #region Mock
            //Mock

            //FinanceService Service Mock
            mockFinanceService.Setup(x => x.GetMethodOFProductionByDeliverableId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);
            //iWBS_DeliverablesRepository Mock
            mockWBS_DeliverablesRepository.Setup(x => x.GetMethodOFProductionByDeliverableId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(lstWBS);

            var financeService = new FinanceServiceMock(
                _iWBS_DeliverablesRepository: mockWBS_DeliverablesRepository.Object);
            //Finance Controller Mock
            var DropDownController = new DropDownControllerMock(financeService: mockFinanceService.Object);

            #endregion

            //Assertions
            mockFinanceService.Verify();
            mockWBS_DeliverablesRepository.Verify();

            var serviceResult = financeService.GetMethodOFProductionByDeliverableId(deliverableId, vendorid, wbsid, isExternal);


            #region "Assertion of GetMethodOFProductionByDeliverableId"
            Assert.IsNotNull(serviceResult);         //Result is not Null
            Assert.AreEqual(serviceResult, lstWBS);  //Asserting the expected return object with dummy data
            Assert.AreEqual(serviceResult.Count, 3); //Assert matching the return data with my input

            var controllerResult = DropDownController.GetMethodOFProductionByDeliverableId(deliverableId, vendorid, wbsid, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResult);//Result is not Null
            Assert.AreEqual(controllerResult.Count, 3);

            isExternal = true;
            var controllerResultForExternalTrue = DropDownController.GetMethodOFProductionByDeliverableId(deliverableId, vendorid, wbsid, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForExternalTrue);//Result is not Null
            Assert.AreSame(controllerResultForExternalTrue[0].Text.Trim(), "Post House");

            filter = "deliverable1";
            var controllerResultForFilter = DropDownController.GetMethodOFProductionByDeliverableId(deliverableId, vendorid, wbsid, isExternal, filter, mrmUserid, networkLogin);
            Assert.IsNotNull(controllerResultForExternalTrue);//Result is not Null
            Assert.AreSame(controllerResultForExternalTrue[0].Text.Trim(), "Post House");
            #endregion
        }