public EventController() { ModelStateWrapper modelStateWrapper = new ModelStateWrapper(ModelState); this.eventService = new EventService(modelStateWrapper, new EventRepository()); this.userService = new UserService(modelStateWrapper, new UserRepository()); }
public QuizQuestionController() { var repo = new QuizQuestionRepository(); var modelStateWrapper = new ModelStateWrapper(this.ModelState); this.Service = new QuizQuestionService(repo, modelStateWrapper); }
public ItemController( IDrugService drugService, IDrugSettingService drugSettingService, IDrugCostService drugCostService, IDrugAppearanceService drugAppearanceService, ICodeFileService codeFileService, ISystemLogService systemLogService) : base(systemLogService) { _modelState = new ModelStateWrapper(ModelState); drugService.InitialiseIValidationDictionary(_modelState); drugSettingService.InitialiseIValidationDictionary(_modelState); drugCostService.InitialiseIValidationDictionary(_modelState); drugAppearanceService.InitialiseIValidationDictionary(_modelState); codeFileService.InitialiseIValidationDictionary(_modelState); _drugService = drugService; _drugSettingService = drugSettingService; _drugCostService = drugCostService; _drugAppearanceService = drugAppearanceService; _codeFileService = codeFileService; }
public void Setup() { _productRepository = new Mock <IProductRepository>(); _modelStateWrapper = new ModelStateWrapper(new ModelStateDictionary()); _productService = new ProductService(_productRepository.Object, null); }
public HomeController() { ModelStateWrapper modelStateWrapper = new ModelStateWrapper(ModelState); this.userService = new UserService(modelStateWrapper, new UserRepository()); }
public void ValidateVehicle_isValid() { var vehicleService = ServiceMiniMart.CreateVehicleService(); var validationDictionary = new ModelStateWrapper(ModelState); vehicleService.ValidateVehicle(GetValidVehicle(), validationDictionary); var errorList = validationDictionary.Errors.Aggregate(string.Empty, (current, error) => current + error.Message + "; "); Assert.IsTrue(validationDictionary.IsValid, errorList); }
public void ValidateUser_Returns_True_For_Valid_User() { //Arrange var password = HashSalt.HashPassword("password", HashSalt.GenerateSalt()); User user = GetValidUserObject(); var validationDictionary = new ModelStateWrapper(ModelState); var userRepository = new Mock<IUserRepository>(); var userService = ServiceMiniMart.CreateUserService(userRepository); //Act userService.ValidateUser(user, validationDictionary); //Assert var errorList = validationDictionary.Errors.Aggregate(string.Empty, (current, error) => current + error.Message + "; "); Assert.IsTrue(validationDictionary.IsValid, errorList); }
public void ValidateUser_Returns_False_For_Used_Email() { //Arrange User user = GetValidUserObject(); user.Email = "*****@*****.**"; var foundUser = new FakeUser { Email = user.Email }; foundUser.SetId(3); var userList = new List<User> { foundUser }.AsQueryable(); var validationDictionary = new ModelStateWrapper(ModelState); var userRepository = new Mock<IUserRepository>(); userRepository.Setup(u => u.FindAll()).Returns(userList); var userService = ServiceMiniMart.CreateUserService(userRepository); //Act userService.ValidateUser(user, validationDictionary); //Assert var errorList = validationDictionary.Errors.Aggregate(string.Empty, (current, error) => current + error.Message + "; "); Assert.IsFalse(validationDictionary.IsValid, errorList); }
public void ValidateUser_Returns_False_For_Missing_Password() { //Arrange User user = GetValidUserObject(); user.HashedPassword = null; var validationDictionary = new ModelStateWrapper(ModelState); var userRepository = new Mock<IUserRepository>(); var userService = ServiceMiniMart.CreateUserService(userRepository); //Act userService.ValidateUser(user, validationDictionary); //Assert var errorList = validationDictionary.Errors.Aggregate(string.Empty, (current, error) => current + error.Message + "; "); Assert.IsFalse(validationDictionary.IsValid, errorList); }