コード例 #1
0
        public async Task ValidSalesPersonEmailAndPassword()
        {
            //Arrange
            SalesPersonBL salesPersonBL = new SalesPersonBL();
            SalesPerson   salesPerson   = new SalesPerson()
            {
                SalesPersonName = "Scott", SalesPersonMobile = "9876543210", Password = "******", Email = "*****@*****.**"
            };
            await salesPersonBL.AddSalesPersonBL(salesPerson);

            bool   isValid      = false;
            string errorMessage = null;

            //Act
            try
            {
                if (salesPerson.Equals((await salesPersonBL.GetSalesPersonByEmailAndPasswordBL(salesPerson.Email, salesPerson.Password))))
                {
                    isValid = true;
                }
            }
            catch (Exception ex)
            {
                isValid      = false;
                errorMessage = ex.Message;
            }
            finally
            {
                //Assert
                Assert.IsTrue(isValid, errorMessage);
            }
        }
コード例 #2
0
        public bool Update(SalesPerson updatedSalesPerson)
        {
            bool salesPersonExists = this.SalesPeople
                                     .Any(salesPerson => updatedSalesPerson.Equals(salesPerson));

            if (!salesPersonExists)
            {
                return(false);
            }

            this.SalesPeople = this.SalesPeople.Select(existingSalesPerson =>
                                                       updatedSalesPerson.Equals(existingSalesPerson)
        ? updatedSalesPerson
        : existingSalesPerson
                                                       ).ToArray();

            return(true);
        }
コード例 #3
0
        public bool Destroy(SalesPerson salesPerson)
        {
            SalesPerson findSalesPerson = this.SalesPeople
                                          .FirstOrDefault(sp => salesPerson.Equals(sp));

            if (Equals(findSalesPerson, null))
            {
                return(false);
            }

            if (findSalesPerson.Sales.Any(sale => !Equals(sale, null)))
            {
                return(false);
            }

            this.SalesPeople = this.SalesPeople
                               .Where(sp => !salesPerson.Equals(sp)).ToArray();

            return(true);
        }
コード例 #4
0
        public bool Create(SalesPerson salesPerson)
        {
            int countOfSalesPeople = this.SalesPeople.Where(sp => !Equals(sp, null)).Count();

            if (countOfSalesPeople == 10)
            {
                return(false);
            }
            bool salesPersonExists = this.SalesPeople
                                     .Any(sp => salesPerson.Equals(sp));

            if (salesPersonExists)
            {
                return(false);
            }

            this.SalesPeople[countOfSalesPeople] = salesPerson;

            return(true);
        }
コード例 #5
0
 public SalesPerson Find(SalesPerson salesPerson) => this.SalesPeople
 .FirstOrDefault(sp => salesPerson.Equals(sp));