コード例 #1
0
 public void EnumerableWithFormatter()
 {
     Approvals.VerifyAll(text, (t) => "" + t.Length);
 }
        public void TestUniqueId()
        {
            var exceptionalId = Exceptional.GenerateUniqueId <Exception>();

            Approvals.Verify(exceptionalId);
        }
コード例 #3
0
        /// <summary>
        /// method to get all ticket which are pending for approvals
        /// </summary>
        /// <param name="logOnId">logOnId=v-aswag</param>
        /// <returns></returns>
        public JsonResult GetPendingApproverList(Users userObj, bool isAllRequest)
        {
            List <MyApprovalData> pendingList = null;

            try
            {
                //In case we are appending domain here, uncomment next line
                if (userObj == null)
                {
                    return(null);
                }
                var isEmailPresent = DbEntity.Users.Where(user => user.LoginId.Equals(userObj.LogOnId)).Select(user => user.Email).FirstOrDefault();
                userObj.LogOnId = isEmailPresent == null ? string.Empty : isEmailPresent.ToString();
                if (isAllRequest)
                {
                    pendingList = (from user in DbEntity.Users
                                   join userbpurolemapping in DbEntity.UserRoleBPUMappings on user.UserId equals userbpurolemapping.UserId
                                   join approval in DbEntity.EMIETicketAprovals on userbpurolemapping.ID equals approval.UserRoleBPUMappingId
                                   join ticket in DbEntity.EMIETickets on approval.TicketId equals ticket.TicketId
                                   join Requestor in DbEntity.Users on ticket.CreatedById equals Requestor.UserId
                                   where (approval.TicketStateId == (int)ApprovalState.Pending && (ticket.FinalCRStatusId == (int)Common.TicketStatus.ApprovalPending || ticket.FinalCRStatusId == (int)Common.TicketStatus.PartiallyApproved))
                                   select new MyApprovalData
                    {
                        TicketId = approval.TicketId,
                        Application = ticket.Application.Application1,
                        RequestedBy = Requestor.UserName,
                        FinalTicketStatus = (int)ticket.FinalCRStatusId,
                    }).Distinct().ToList();
                }
                else
                {
                    pendingList = (from user in DbEntity.Users
                                   join userbpurolemapping in DbEntity.UserRoleBPUMappings on user.UserId equals userbpurolemapping.UserId
                                   join approval in DbEntity.EMIETicketAprovals on userbpurolemapping.ID equals approval.UserRoleBPUMappingId
                                   join ticket in DbEntity.EMIETickets on approval.TicketId equals ticket.TicketId
                                   join Requestor in DbEntity.Users on ticket.CreatedById equals Requestor.UserId
                                   where (userbpurolemapping.IsActive == true && user.Email.Equals(userObj.LogOnId.Trim()) && approval.TicketStateId == (int)ApprovalState.Pending && (ticket.FinalCRStatusId == (int)Common.TicketStatus.ApprovalPending || ticket.FinalCRStatusId == (int)Common.TicketStatus.PartiallyApproved))
                                   select new MyApprovalData
                    {
                        TicketId = approval.TicketId,
                        Application = ticket.Application.Application1,
                        RequestedBy = Requestor.UserName,
                        FinalTicketStatus = (int)ticket.FinalCRStatusId
                    }).Distinct().ToList();
                }
                foreach (var ticketitem in pendingList)
                {
                    List <Approvals> approvals = (
                        from ticket in DbEntity.EMIETickets
                        join ticketApproval in DbEntity.EMIETicketAprovals on ticket.TicketId equals ticketApproval.TicketId
                        join userBpurolemapping in DbEntity.UserRoleBPUMappings on ticketApproval.UserRoleBPUMappingId equals userBpurolemapping.ID
                        join user in DbEntity.Users on userBpurolemapping.UserId equals user.UserId
                        join role in DbEntity.Roles on userBpurolemapping.RoleId equals role.RoleId
                        where (ticket.TicketId == ticketitem.TicketId)
                        //Approvers of ticket
                        select new Approvals
                    {
                        Approver = new Users
                        {
                            UserId = user.UserId,
                            UserName = user.UserName,
                            UserRole = new Roles
                            {
                                RoleId = role.RoleId,
                                RoleName = role.RoleName
                            },
                            Email = user.Email
                        },
                        ApprovalState = (ApprovalState)ticketApproval.TicketStateId,
                        ApproverComments = ticketApproval.ApproverComments
                    }
                        ).ToList();

                    ticketitem.Approvers = approvals;
                }
                List <MyApprovalData> removerApproversItem = new List <MyApprovalData>();
                foreach (var item in pendingList)
                {
                    if (item.FinalTicketStatus > (int)TicketStatus.ApprovalPending)
                    {
                        //GET ALL EMIE APPROVERS
                        List <Approvals> approversLIst = item.Approvers.Where(approver => approver.Approver.UserRole.RoleId == 4).ToList();
                        if (approversLIst.Count >= 1)
                        {
                            //get approved emie approver
                            var isapproved = approversLIst.Where(approver => approver.ApprovalState == Common.ApprovalState.Approved).ToList();
                            if (isapproved.Count >= 1)
                            {
                                //remove all emie approvers and insert single approved emie  approver
                                foreach (var approveritem in approversLIst)
                                {
                                    item.Approvers.Remove(approveritem);
                                }
                                item.Approvers.Add(isapproved[0]);
                                if (!isAllRequest)
                                {
                                    //check other approvers if they are logged in user and in approved state then remove it from my pending approver list
                                    List <Approvals> approverslisttemp = item.Approvers.Where(approver => approver.Approver.UserId == userObj.UserId &&
                                                                                              approver.Approver.UserRole.RoleId != 4).ToList();
                                    if (approverslisttemp.Count == 0)
                                    {
                                        removerApproversItem.Add(item);
                                    }
                                }
                            }
                            else
                            {
                                //remove all emie approvers
                                foreach (var approveritem in approversLIst)
                                {
                                    item.Approvers.Remove(approveritem);
                                }
                                //check if logged user is in emie approver
                                Approvals loggeduser = approversLIst.Where(approver => approver.Approver.UserId == userObj.UserId).FirstOrDefault();
                                if (loggeduser != null)
                                {
                                    loggeduser.Approver.Email = Constants.EMIEChampGroup;
                                    item.Approvers.Add(loggeduser);
                                }
                                else
                                {
                                    Approvals approver = new Approvals()
                                    {
                                        Approver = userObj, ApprovalState = Common.ApprovalState.Pending, IsActive = (bool)userObj.IsActive
                                    };
                                    approver.Approver.Email = Constants.EMIEChampGroup;
                                    item.Approvers.Add(approver);
                                }
                            }
                        }
                    }
                    else//make email as "EMIE CHAMP GROUP" for pending emie champ
                    {
                        List <Approvals> approversLIst = item.Approvers.Where(x => x.Approver.UserRole.RoleId == 4).ToList();
                        if (approversLIst.Count > 0)
                        {
                            approversLIst[0].Approver.Email = Constants.EMIEChampGroup;
                            var allemeiApprovers = item.Approvers.Where(x => x.Approver.UserRole.RoleId == 4).ToList();
                            if (allemeiApprovers.Count > 0)
                            {
                                foreach (var approveritem in allemeiApprovers)
                                {
                                    item.Approvers.Remove(approveritem);
                                }
                            }
                            //add llogged user if emie approver
                            var isloggedUserIsEMIE = allemeiApprovers.Where(approver => approver.Approver.UserId == userObj.UserId).FirstOrDefault();
                            if (isloggedUserIsEMIE != null)
                            {
                                isloggedUserIsEMIE.Approver.Email = Constants.EMIEChampGroup;
                                item.Approvers.Add(isloggedUserIsEMIE);
                            }
                            else
                            {
                                Approvals approver = new Approvals()
                                {
                                    Approver = userObj, ApprovalState = Common.ApprovalState.Pending, IsActive = (bool)userObj.IsActive
                                };
                                approver.Approver.Email = Constants.EMIEChampGroup;
                                item.Approvers.Add(approver);
                            }
                            //this code is kept for future reference
                            //else
                            //    item.Approvers.Add(approversLIst[0]);
                        }
                    }
                }

                foreach (var item in removerApproversItem)
                {
                    pendingList.Remove(item);
                }
            }

            catch (Exception)
            {
                throw;
            }
            return(Json(pendingList, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
 public void ClassWithDateTime()
 {
     Approvals.Verify(Decompile(AssemblyWeaver.AfterAssemblyPath, "ClassWithDateTime"));
 }
コード例 #5
0
        public void Test_CreateLedgerRecords_With_Two_Accounts_And_Two_Trans()
        {
            //Arrange
            var accountHistoryData = new []
            {
                new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount,
                                                      new GLHistory()
                {
                    PtdCredit = 1,
                    PtdDebit  = 3
                },
                                                      new AH()
                {
                    FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID,
                    YtdBalance  = 6
                }),
                new PXResult <Account, GLHistory, AH>(_accountDataContext.LiablityAccount,
                                                      new GLHistory()
                {
                    PtdCredit = 9,
                    PtdDebit  = 2
                },
                                                      new AH()
                {
                    FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID,
                    YtdBalance  = 15
                })
            };

            GAFRepositoryMock.Setup(repo => repo.GetAccountsWithDataToCalcBeginBalancesExcludingYTDNetIncAcc(_branchDataContext.Branch.BranchID,
                                                                                                             _branchDataContext.Branch.LedgerID,
                                                                                                             _finPeriodDataContext.FinPeriod201503.FinPeriodID))
            .Returns(accountHistoryData);

            var glTrans = new GLTran[] { new GLTran()
                                         {
                                             AccountID   = _accountDataContext.AssetAccount.AccountID,
                                             DebitAmt    = 5,
                                             CreditAmt   = 1,
                                             TranDesc    = "TranDesc1",
                                             TranDate    = new DateTime(2015, 1, 1),
                                             BatchNbr    = "BN0001",
                                             RefNbr      = "REF0001",
                                             Module      = BatchModule.AP,
                                             ReferenceID = VendorDataContext.VendorID
                                         },
                                         new GLTran()
                                         {
                                             AccountID   = _accountDataContext.AssetAccount.AccountID,
                                             DebitAmt    = 6,
                                             CreditAmt   = 3,
                                             TranDesc    = "TranDesc2",
                                             TranDate    = new DateTime(2015, 1, 2),
                                             BatchNbr    = "BN0002",
                                             RefNbr      = "REF0002",
                                             Module      = BatchModule.AR,
                                             ReferenceID = CustomerDataContext.CustomerID
                                         },
                                         new GLTran()
                                         {
                                             AccountID   = _accountDataContext.LiablityAccount.AccountID,
                                             DebitAmt    = 9,
                                             CreditAmt   = 15,
                                             TranDesc    = "TranDesc3",
                                             TranDate    = new DateTime(2015, 1, 3),
                                             BatchNbr    = "BN0003",
                                             RefNbr      = "REF0003",
                                             Module      = BatchModule.SO,
                                             ReferenceID = CustomerDataContext.CustomerID
                                         },
                                         new GLTran()
                                         {
                                             AccountID   = _accountDataContext.LiablityAccount.AccountID,
                                             DebitAmt    = 20,
                                             CreditAmt   = 7,
                                             TranDesc    = "TranDesc4",
                                             TranDate    = new DateTime(2015, 1, 4),
                                             BatchNbr    = "BN0004",
                                             RefNbr      = "REF0004",
                                             Module      = BatchModule.PO,
                                             ReferenceID = VendorDataContext.VendorID
                                         } };

            GAFRepositoryMock.Setup(repo => repo.GetPostedGLTrans(_branchDataContext.Branch.BranchID,
                                                                  _branchDataContext.Branch.LedgerID,
                                                                  It.IsAny <int?>(),
                                                                  _finPeriodDataContext.FinPeriod201503.FinPeriodID))
            .Returns <int?, int?, int?, string>((b, l, accountID, fp) => glTrans.Where(glTran => glTran.AccountID == accountID));

            //Action
            var ledgerRecords = _glgafLedgerRecordsCreator.CreateLedgerRecords(_gafPeriodDataContext.GAFPeriod);

            //Assert
            Approvals.VerifyAll(ledgerRecords, "ledgerRecords", record => record.Dump());
        }
コード例 #6
0
 public static void VerifySet <T>(IEnumerable <T> enumerable, string label, Func <T, string> formatter) where T : IComparable <T>
 {
     Approvals.VerifyAll(GetSorted(enumerable), label, formatter);
 }
コード例 #7
0
 public static void VerifySet <T>(string header, IEnumerable <T> enumerable, Func <T, string> formatter) where T : IComparable <T>
 {
     Approvals.VerifyAll(header, GetSorted(enumerable), formatter);
 }
コード例 #8
0
 public void DictionarySimple()
 {
     Approvals.VerifyAll(FireFlyMap());
 }
コード例 #9
0
 public void Dictionary()
 {
     Approvals.VerifyAll("Firefly", FireFlyMap());
 }
コード例 #10
0
 public void EnumerableWithLabelAndFormatter()
 {
     Approvals.VerifyAll(text, "collection", (t) => "" + t.Length);
 }
コード例 #11
0
        public void EnumerableWithHeaderAndFormatter()
        {
            var word = "Llewellyn";

            Approvals.VerifyAll(word, word.ToCharArray(), (c) => c + " => " + (int)c);
        }
コード例 #12
0
        public void TestBytes()
        {
            var path = PathUtilities.GetDirectoryForCaller();

            Approvals.VerifyBinaryFile(File.ReadAllBytes(path + "a.png"), "png");
        }
コード例 #13
0
 public void EnumerableWithLabel()
 {
     Approvals.VerifyAll(text, "collection");
 }
コード例 #14
0
 public void Text()
 {
     Approvals.Verify("should be approved");
 }
        public void NamespaceFilters()
        {
            var namespaces = new[] { GetType().Namespace, "", null, typeof(string).Namespace, typeof(Approvals).Namespace, typeof(Logger).Namespace };

            Approvals.VerifyAll("Namespace is part of Approvals", namespaces, n => $"{n} = {AttributeStackTraceParser.IsNamespaceApprovals(n)}");
        }
コード例 #16
0
 public void DictionaryCustom()
 {
     Approvals.VerifyAll("Firefly", FireFlyMap(), (k, v) => "\"{0}\" => {1}".FormatWith(k, v));
 }
コード例 #17
0
 public void TestObjectDeepCloneToBaseline() //Ensure all required fields, collections items etc
 {
     //Ensure all field have been copied by using an approved baseline
     //This is useful in testing breaking changes
     Approvals.Verify(JsonConvert.SerializeObject(this.clonedObject));
 }
コード例 #18
0
 public void DictionaryCustomNoHeader()
 {
     Approvals.VerifyAll(FireFlyMap(), (k, v) => "\"{0}\" => {1}".FormatWith(k, v));
 }
コード例 #19
0
 public static void VerifySet <T>(string header, IEnumerable <T> enumerable, string label) where T : IComparable <T>
 {
     Approvals.VerifyAll(header, GetSorted(enumerable), label);
 }
コード例 #20
0
        public void TestExistFileIsApproved()
        {
            var basePath = Environment.CurrentDirectory + @"\..\..\";

            var original = basePath + "a.png";
            var copy     = basePath + "a1.png";

            File.Copy(original, copy);
            Approvals.Approve(new ExistingFileWriter(copy), Approvals.GetDefaultNamer(), Approvals.GetReporter());
        }
コード例 #21
0
 public void ClassWithBrokenReplacement()
 {
     Approvals.Verify(Decompile(AssemblyWeaver.AfterAssemblyPath, "ClassWithBrokenReplacement"));
 }
コード例 #22
0
        public void ApprovalTestswithVersionCompareDynamic()
        {
            var actual = Request.RestRequest("https://api.exchangeratesapi.io/", "2010-01-14", "GET");

            Approvals.Verify(ScrubDynamic(actual.Content));
        }
コード例 #23
0
 public void ClassWithGenericUsage()
 {
     Approvals.Verify(Decompile(AssemblyWeaver.AfterAssemblyPath, "ClassWithGenericUsage"));
 }
コード例 #24
0
 public void Should_return_a_build_Info_When_Json_content_is_the_one_of_a_master_build()
 {
     Approvals.Verify(BuildBuildInfoForFile("AppVeyorResult_master.json"));
 }
コード例 #25
0
        public void Test_CreateLedgerRecords_That_Adjustment_Period_Is_Joined_To_Last_Year_Period_And_Is_Exported()
        {
            //Arrange
            var accountHistoryPairs = new[]
            {
                new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount,
                                                      new GLHistory()
                {
                    FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID
                },
                                                      new AH()),
                new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount,
                                                      new GLHistory()
                {
                    FinPeriodID = _finPeriodDataContext.FinPeriod201504.FinPeriodID
                },
                                                      new AH())
            };

            GAFRepositoryMock.Setup(repo => repo.GetAccountsWithDataToCalcBeginBalancesExcludingYTDNetIncAcc(_branchDataContext.Branch.BranchID,
                                                                                                             _branchDataContext.Branch.LedgerID,
                                                                                                             It.IsAny <string>()))
            .Returns <int?, int?, string>((b, l, finPeriodID) => accountHistoryPairs.Where(pair => ((GLHistory)pair).FinPeriodID == finPeriodID));

            GAFRepositoryMock.Setup(repo => repo.FindLastYearNotAdjustmentPeriod(_finPeriodDataContext.FinPeriod201503.FinYear))
            .Returns(_finPeriodDataContext.FinPeriod201503);

            GAFRepositoryMock.Setup(repo => repo.GetAdjustmentFinPeriods(_finPeriodDataContext.FinPeriod201503.FinYear))
            .Returns(_finPeriodDataContext.FinPeriod201504.SingleToArray());

            var glTrans = new GLTran[]
            {
                new GLTran()
                {
                    AccountID   = _accountDataContext.AssetAccount.AccountID,
                    DebitAmt    = 5,
                    CreditAmt   = 1,
                    TranDesc    = "TranDesc1",
                    TranDate    = new DateTime(2015, 1, 1),
                    BatchNbr    = "BN0001",
                    RefNbr      = "REF0001",
                    Module      = BatchModule.AP,
                    ReferenceID = VendorDataContext.VendorID,
                    FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID
                },
                new GLTran()
                {
                    AccountID   = _accountDataContext.AssetAccount.AccountID,
                    DebitAmt    = 6,
                    CreditAmt   = 3,
                    TranDesc    = "TranDesc2",
                    TranDate    = new DateTime(2015, 1, 2),
                    BatchNbr    = "BN0002",
                    RefNbr      = "REF0002",
                    Module      = BatchModule.AR,
                    ReferenceID = CustomerDataContext.CustomerID,
                    FinPeriodID = _finPeriodDataContext.FinPeriod201504.FinPeriodID
                }
            };

            GAFRepositoryMock.Setup(repo => repo.GetPostedGLTrans(_branchDataContext.Branch.BranchID,
                                                                  _branchDataContext.Branch.LedgerID,
                                                                  _accountDataContext.AssetAccount.AccountID,
                                                                  It.IsAny <string>()))
            .Returns <int?, int?, int?, string>((b, l, a, finPeriodID) => glTrans.Where(glTran => glTran.FinPeriodID == finPeriodID));

            //Action
            var ledgerRecords = _glgafLedgerRecordsCreator.CreateLedgerRecords(_gafPeriodDataContext.GAFPeriod);

            //Assert
            Approvals.VerifyAll(ledgerRecords, "ledgerRecords", record => record.Dump());
        }
コード例 #26
0
ファイル: NotHandled.cs プロジェクト: ropean/Usable
 public void ReturnLocalDisposable()
 {
     Approvals.Verify(Decompiler.Decompile(AssemblyWeaver.AfterAssemblyPath, "NotHandled::ReturnLocalDisposable"));
 }
コード例 #27
0
 public void OneTimeSetup()
 {
     Approvals.RegisterDefaultNamerCreation(() => new CyberDojoNamer());
 }
コード例 #28
0
ファイル: NotHandled.cs プロジェクト: ropean/Usable
 public void UsingArray()
 {
     Approvals.Verify(Decompiler.Decompile(AssemblyWeaver.AfterAssemblyPath, "NotHandled::UsingArray"));
 }
コード例 #29
0
 public void DictionaryCustomNoHeader()
 {
     Approvals.VerifyAll(FireFlyMap(), (k, v) => $"\"{k}\" => {v}");
 }
コード例 #30
0
        public static void Verify(IGraphNode input)
        {
            var dotGraph = DotGraph.DotGraph.FromPipeline(input);

            Approvals.Verify(WriterFactory.CreateTextWriter(dotGraph.ToString(), "dot"));
        }