コード例 #1
0
 public void CreateUserProfile(User user, string phoneNumber)
 {
     var profile = new UserProfile
                       {
                           User = user,
                           Balance = 0,
                           PhoneNumber = phoneNumber
                       };
     UnitOfWork.GetRepository<UserProfile>().Insert(profile);
     UnitOfWork.Save();
 }
コード例 #2
0
        public FinanceControllerTests()
        {
            _unitOfWork = new UnitOfWorkMock();
            _controller = new FinanceController(_unitOfWork);

            _currentUser = new User {UserName = "******"};
            _currentUserProfile = new UserProfile {User = _currentUser};

            _unitOfWork.GetRepository<User>().Insert(_currentUser);
            _unitOfWork.GetRepository<UserProfile>().Insert(_currentUserProfile);
            _unitOfWork.Save();

            _controller.ControllerContext = CreateControllerContext(_currentUser);
        }
コード例 #3
0
        public void UserDetailsPost_ModelStateIsValid_RedirectedToUserList()
        {
            // Arrange
            var profile = new UserProfile();
            var viewModel = new UserDetailsViewModel { UserProfile = profile };
            var profileService = new Mock<IProfileService>();
            var controller = new AdminController(null, profileService.Object);

            // Act
            var result = controller.UserDetails(viewModel);

            // Assert
            var viewResult = (ViewResult)result ;
            viewResult.ViewName.Should().Be("Users");
        }
コード例 #4
0
        public ContentControllerTests()
        {
            _unitOfWork = new UnitOfWorkMock();
            _fileStorageManager = new FileStorageManagerMock();

            _currentUser = new User {UserName = "******"};
            _currentUserProfile = new UserProfile {User = _currentUser};
            _unitOfWork.GetRepository<User>().Insert(_currentUser);
            _unitOfWork.GetRepository<UserProfile>().Insert(_currentUserProfile);

            _controller = new ContentController(_unitOfWork,
                                                _fileStorageManager,
                                                new FinanceService(_unitOfWork));
            _controller.ControllerContext = CreateControllerContext();
            InitUnitOfWork(_unitOfWork);
        }
コード例 #5
0
        public void UserDetails_Simple_UserInformationProvided()
        {
            // Arrange
            var membershipService = new Mock<IMembershipService>();
            var profileService = new Mock<IProfileService>();
            var user = new User();
            var userProfile = new UserProfile();
            membershipService.Setup(s => s.GetUser(3)).Returns(user);
            profileService.Setup(s => s.GetUserProfile(user)).Returns(userProfile);
            var controller = new AdminController(membershipService.Object,profileService.Object);

            // Act
            var result = controller.UserDetails(3);

            // Assert
            var viewModel = (UserDetailsViewModel)result.Model;
            viewModel.User.Should().Be(user);
            viewModel.UserProfile.Should().Be(userProfile);
        }
コード例 #6
0
        public void UserHasPermissions_UserNotOrderedPackage_UserHasNoPermissions()
        {
            // Arrange
            var unitOfWork = new UnitOfWorkMock();
            var user = new User();
            var userProfile = new UserProfile {User = user};
            var package = new ContentPackage {Owner = new User()};
            unitOfWork.GetRepository<User>().Insert(user);
            unitOfWork.GetRepository<UserProfile>().Insert(userProfile);
            unitOfWork.GetRepository<ContentPackage>().Insert(package);
            unitOfWork.Save();

            // Act
            var financeService = new FinanceService(unitOfWork);
            var userHasPermissions = financeService.UserHasPermissions(user, package);

            // Assert
            userHasPermissions.Should().BeFalse();
        }
コード例 #7
0
        private ContentPackage CreatePackage(int price = 100)
        {
            _ownerUser = new User {UserName = "******"};
            _ownerProfile = new UserProfile {User = _ownerUser};
            _unitOfWork.GetRepository<User>().Insert(_ownerUser);
            _unitOfWork.GetRepository<UserProfile>().Insert(_ownerProfile);

            var package = new ContentPackage
                          {
                              Price = price,
                              Owner = _ownerUser
                          };

            return package;
        }