예제 #1
0
        public void UpdateStatusFailureNotExist()
        {
            PhoneOrderRepository   phoneOrderRepository = new PhoneOrderRepository();
            ChangeStatusRequestDTO request = new ChangeStatusRequestDTO();

            request.Id = Guid.NewGuid();
            IQueryable <PhoneOrderEntity> plist = new List <PhoneOrderEntity> {
                new PhoneOrderEntity {
                    FirstName = "Adam", Id = Guid.NewGuid()
                }
            }.AsQueryable();
            Mock <ITable <PhoneOrderEntity> > mockPhoneOrders = mockFactory.CreateMock <ITable <PhoneOrderEntity> >();
            bool rval;

            request.Status = PhoneOrderEntity.ApprovalStatus.Rejected;

            mockPhoneOrders.As <IQueryable <PhoneOrderEntity> >().Expects.One.GetProperty(m => m.Provider).WillReturn(plist.Provider);
            mockPhoneOrders.As <IQueryable <PhoneOrderEntity> >().Expects.One.GetProperty(m => m.Expression).WillReturn(plist.Expression);
            //mockPhoneOrders.As<IQueryable<PhoneOrderEntity>>().Expects.AtLeastOne.GetProperty(m=>m.ElementType).WillReturn(plist.ElementType);
            //mockPhoneOrders.As<IQueryable<PhoneOrderEntity>>().Expects.AtLeastOne.Method(m=>m.GetEnumerator()).WillReturn(plist.GetEnumerator());
            mockPhoneOrders.Expects.No.Method(m => m.Update(null)).WithAnyArguments();

            phoneOrderRepository.SetPrivateField("phoneOrders", mockPhoneOrders.MockObject);

            rval = phoneOrderRepository.UpdateStatus(request);
            Assert.IsFalse(rval);
        }
예제 #2
0
        public virtual bool UpdateStatus(ChangeStatusRequestDTO request)
        {
            IQueryable <PhoneOrderEntity> orders = PhoneOrders.Where(x => x.Id == request.Id);

            if (orders.Count() != 1)
            {
                return(false);
            }
            PhoneOrderEntity order = orders.First();

            order.Status = request.Status;
            PhoneOrders.Update(order);
            return(true);
        }