public void CreateUserProfile(User user, string phoneNumber) { var profile = new UserProfile { User = user, Balance = 0, PhoneNumber = phoneNumber }; UnitOfWork.GetRepository<UserProfile>().Insert(profile); UnitOfWork.Save(); }
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); }
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"); }
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); }
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); }
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(); }
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; }