コード例 #1
0
        public void Call_LoggedInUser_GetUserId_Once()
        {
            // Arrange
            var domainService    = new Mock <IDomainService>();
            var userService      = new Mock <IUserService>();
            var loggedInUser     = new Mock <ILoggedInUser>();
            var sellerController = new SellerController(userService.Object, domainService.Object, loggedInUser.Object);

            var userId = "userId";

            loggedInUser.Setup(l => l.GetUserId()).Returns(userId);

            var domains = new List <Domain>()
            {
                new Domain()
                {
                    Name = "name"
                }
            };

            domainService.Setup(d => d.GetSellerPendingDomainsByUserId(userId)).Returns(domains.AsQueryable <Domain>());

            // Act
            sellerController.Pending();

            // Assert
            loggedInUser.Verify(l => l.GetUserId(), Times.Once());
        }