コード例 #1
0
            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");
            }
コード例 #2
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="listLogic"></param>
 /// <param name="profileLogic"></param>
 /// <param name="logRepo"></param>
 public RecentItemController(IListLogic listLogic, IUserProfileLogic profileLogic, IRecentlyViewedListLogic recentlyViewedLogic,
                             IRecentlyOrderedListLogic recentlyOrderedLogic, IListService listService, IEventLogRepository logRepo)  : base(profileLogic)
 {
     _repo = listLogic;
     _recentlyViewedLogic  = recentlyViewedLogic;
     _recentlyOrderedLogic = recentlyOrderedLogic;
     _listService          = listService;
     _log = logRepo;
 }
コード例 #3
0
            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
コード例 #4
0
            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");
            }
コード例 #5
0
            public void BadBranchId_ReturnsNull()
            {
                // arrange
                IRecentlyViewedListLogic testunit    = MakeTestsObject();
                UserSelectedContext      testcontext = new UserSelectedContext {
                    BranchId   = "XXX",
                    CustomerId = "123456"
                };
                UserProfile fakeUser = new UserProfile {
                    UserId = new Guid("dddddddddddddddddddddddddddddddd")
                };
                bool headerOnly = false;

                // act
                ListModel results = testunit.ReadList(fakeUser, testcontext, headerOnly);

                // assert
                results.Should()
                .BeNull();
            }
コード例 #6
0
            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");
            }
コード例 #7
0
            public void GoodCustomerIdAndBranch_ReturnsExpectedList()
            {
                // arrange
                IRecentlyViewedListLogic testunit    = MakeTestsObject();
                UserSelectedContext      testcontext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };
                int         expectedListId = 1;
                UserProfile fakeUser       = new UserProfile {
                    UserId = new Guid("dddddddddddddddddddddddddddddddd")
                };
                bool headerOnly = false;

                // act
                ListModel results = testunit.ReadList(fakeUser, testcontext, headerOnly);

                // assert
                results.ListId
                .Should()
                .Be(expectedListId);
            }