public void GoodCustomerIdAndBranch_CallsDeleteOldRecentlyViewedDetail()
            {
                // arrange
                Mock <IRecentlyViewedListHeadersRepository> mockHeadersRepo;
                Mock <IRecentlyViewedListDetailsRepository> mockDetailsRepo;
                IRecentlyViewedListLogic testunit = MakeTestObject(out mockHeadersRepo, out mockDetailsRepo);

                mockHeadersRepo.Setup(h => h.GetRecentlyViewedHeader(It.IsAny <Guid>(),
                                                                     It.Is <UserSelectedContext>(c => c.BranchId == "FUT" &&
                                                                                                 c.CustomerId == "123456")))
                .Returns(new RecentlyViewedListHeader {
                    BranchId       = "FUT",
                    CustomerNumber = "123456",
                    Id             = 1
                });

                UserSelectedContext testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();

                // act
                testunit.DeleteAll(fakeUser, testcontext);

                // assert - Always returns what is setup provided the mock is called
                mockDetailsRepo.Verify(h => h.DeleteOldRecentlyViewed(It.IsAny <long>(), It.IsAny <int>()), Times.Once(), "Error updating");
            }
            public void BadCustomerIdAndBranch_CompletesWithoutError()
            {
                // arrange
                IRecentlyViewedListLogic testunit    = MakeTestsObject();
                UserSelectedContext      testcontext = new UserSelectedContext {
                    BranchId   = "XXX",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();

                // act
                testunit.DeleteAll(fakeUser, testcontext);

                // assert - Always returns what is setup provided the mock is called
            } // works differently if you want to verify a mock is called; we can't go through autofac
Пример #3
0
        public Models.OperationReturnModel <bool> DeleteRecent()
        {
            Models.OperationReturnModel <bool> retVal = new Models.OperationReturnModel <bool>();
            try
            {
                _recentlyViewedLogic.DeleteAll(this.AuthenticatedUser, this.SelectedUserContext);
                retVal.SuccessResponse = true;
                retVal.IsSuccess       = true;
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("DeleteRecent SelectedUserContext.CustomerID=" + SelectedUserContext.CustomerId, ex);
                retVal.ErrorMessage = ex.Message;
                retVal.IsSuccess    = false;
            }

            return(retVal);
        }