Beispiel #1
0
        public void HertzAddUpdateCsAgent_Negative(CsAgentModel csAgent, string agentRoleName, int errorCode, string errorMessage)
        {
            CsAgentController CsAgentController = new CsAgentController(Database, TestStep);

            try
            {
                CsAgentRoleModel csAgentRole   = CsAgentController.GetFromDBRoleID(agentRoleName);
                decimal          caAgentRoleID = csAgentRole.ID;
                csAgent.ROLEID = caAgentRoleID;
                TestStep.Start($"Make HertzAwardLoyaltyCurrency Call", $"Add member call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => CsAgentController.AddCsAgent(csAgent));
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzAwardLoyaltyCurrency call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #2
0
        public void HertzAddUpdateCsAgent_Positive(CsAgentModel csAgent, string agentRoleName, bool UpdateCsAgent)
        {
            CsAgentController CsAgentController = new CsAgentController(Database, TestStep);
            CsAgentModel      csAgentOut;

            try
            {
                CsAgentRoleModel csAgentRole   = CsAgentController.GetFromDBRoleID(agentRoleName);
                decimal          caAgentRoleID = csAgentRole.ID;
                csAgent.ROLEID = caAgentRoleID;
                TestStep.Start($"Make HertzAddUpdateCSAgent Call", "CSAgent should be added successfully");
                csAgentOut = CsAgentController.AddCsAgent(csAgent);
                AssertModels.AreEqualWithAttribute(csAgent, csAgentOut);
                TestStep.Pass("CsAgent was added successfully and CsAgent object was returned", csAgentOut.ReportDetail());

                TestStep.Start($"Verify CsAgent in {CsAgentModel.TableName} table", "Database CsAgent should match created CsAgent");
                CsAgentModel dbCsAgent = CsAgentController.GetFromDB(csAgentOut.USERNAME);
                AssertModels.AreEqualWithAttribute(csAgentOut, dbCsAgent);
                TestStep.Pass("CsAgent created matches CsAgent in database", dbCsAgent.ReportDetail());
                if (UpdateCsAgent)
                {
                    csAgentOut.LASTNAME     = csAgentOut.LASTNAME + "Updated";
                    csAgentOut.EMAILADDRESS = "*****@*****.**";
                    TestStep.Start($"Make HertzAddUpdateCSAgent Call for updating Last Name and Email", "CSAgent should be updated successfully");
                    CsAgentModel csAgentOutUpdated = CsAgentController.AddCsAgent(csAgentOut);
                    AssertModels.AreEqualWithAttribute(csAgentOutUpdated, csAgentOut);
                    TestStep.Pass("CsAgent was added successfully and CsAgent object was returned", csAgentOutUpdated.ReportDetail());

                    TestStep.Start($"Verify CsAgent is updated in {CsAgentModel.TableName} table", "Database CsAgent should match updated CsAgent");
                    CsAgentModel dbCsAgentUpdated = CsAgentController.GetFromDB(csAgentOutUpdated.USERNAME);
                    AssertModels.AreEqualWithAttribute(csAgentOutUpdated, dbCsAgentUpdated);
                    TestStep.Pass("CsAgent created matches CsAgent in database", dbCsAgentUpdated.ReportDetail());
                }
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
        public CsAgentRoleModel GetFromDBRoleID(string agentRole, string userNameQuery = null)
        {
            string query = String.Empty;

            if (agentRole == null && !String.IsNullOrEmpty(userNameQuery))
            {
                query = userNameQuery;
            }
            else
            {
                query = $@"select* from bp_htz.lw_csrole cs
                        where cs.name = '{agentRole}'";
            }
            CsAgentRoleModel csAgentRole = dbContext.QuerySingleRow <CsAgentRoleModel>(query);

            return(csAgentRole);
        }