コード例 #1
0
        public void Call_DomainService_AddDomain_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);

            AddDomainViewModel addDomainViewModel = new AddDomainViewModel()
            {
                Name        = "name",
                Description = "description"
            };

            // Act
            sellerController.AddDomain(addDomainViewModel);

            // Assert
            domainService.Verify(
                d => d.AddDomain(addDomainViewModel.Name, addDomainViewModel.Description, userId), Times.Once());
        }
コード例 #2
0
        public void Set_TempData_SuccessMessage()
        {
            // 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);

            AddDomainViewModel addDomainViewModel = new AddDomainViewModel()
            {
                Name        = "name",
                Description = "description"
            };

            // Act
            sellerController.AddDomain(addDomainViewModel);

            // Assert
            sellerController.ShouldHaveTempDataProperty("Success", "Added successfully!");
        }