public void AnyCustomerIdAndBranch_CallsSaveDetailEveryTime()
            {
                // arrange
                Mock <IRecentlyViewedListHeadersRepository> mockHeadersRepo;
                Mock <IRecentlyViewedListDetailsRepository> mockDetailsRepo;
                IRecentlyViewedListLogic testunit    = MakeTestObject(out mockHeadersRepo, out mockDetailsRepo);
                UserSelectedContext      testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile();
                string      testRecentViewedItemNumber = "111111";

                // act
                testunit.PostRecentView(fakeUser, testcontext, testRecentViewedItemNumber);

                // assert - Always returns what is setup provided the mock is called
                mockDetailsRepo.Verify(h => h.Save(It.IsAny <RecentlyViewedListDetail>()), Times.Once(), "Error updating");
            }
Пример #2
0
        public Models.OperationReturnModel <bool> Recent(string itemnumber)
        {
            Models.OperationReturnModel <bool> retVal = new Models.OperationReturnModel <bool>();
            try
            {
                _recentlyViewedLogic.PostRecentView(this.AuthenticatedUser,
                                                    this.SelectedUserContext,
                                                    itemnumber);
                retVal.SuccessResponse = true;
                retVal.IsSuccess       = retVal.SuccessResponse;
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("Recent(string itemnumber)", ex);
                retVal.ErrorMessage = ex.Message;
                retVal.IsSuccess    = false;
            }

            return(retVal);
        }
            public void HeaderWritten_HasTheRightUserId()
            {
                // arrange
                Mock <IRecentlyViewedListHeadersRepository> mockHeadersRepo;
                Mock <IRecentlyViewedListDetailsRepository> mockDetailsRepo;
                IRecentlyViewedListLogic testunit    = MakeTestObject(out mockHeadersRepo, out mockDetailsRepo);
                UserSelectedContext      testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile {
                    UserId = new Guid("dddddddddddddddddddddddddddddddd")
                };
                string testRecentViewedItemNumber = "111111";

                // act
                testunit.PostRecentView(fakeUser, testcontext, testRecentViewedItemNumber);

                // assert - Always returns what is setup provided the mock is called
                mockHeadersRepo.Verify(h => h.Save(It.Is <RecentlyViewedListHeader>(head => head.UserId == new Guid("dddddddddddddddddddddddddddddddd"))), Times.Once(), "Error updating");
            }