Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 5
0
        public HomeController()
        {
            ModelStateWrapper modelStateWrapper = new ModelStateWrapper(ModelState);

            this.userService = new UserService(modelStateWrapper, new UserRepository());
        }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }