Пример #1
0
 public UtilityModel Get()
 {
     return(new UtilityModel()
     {
         Name = StringsGenerators.GenerateString(10),
         Description = StringsGenerators.GenerateString(60),
     });
 }
Пример #2
0
        public UnitTypeModel Get()
        {
            var model = new UnitTypeModel();

            model.Description = StringsGenerators.GenerateString(199);
            model.Name        = StringsGenerators.GenerateString(10);

            return(model);
        }
Пример #3
0
        public void Can_not_create_utility_with_invalid_name_lenth()
        {
            var companyModel = CreateCompany();
            var utilityModel = _utilityModelGenerator.Get(companyModel);

            utilityModel.Name = StringsGenerators.GenerateString(65);
            var response = _utilitySerivce.Create(utilityModel);

            AssertValidationErrorIsInList(string.Format(_translationsService.GetTranslationByKey("validations.lengthBetween"), 1, 60), response);
        }
Пример #4
0
        public void Can_not_create_company_with_invalid_name_length()
        {
            var companyModel = _companyGenerator.Get();

            companyModel.Name = StringsGenerators.GenerateString(3);

            var response = _companyService.Create(companyModel);

            AssertValidationErrorIsInList(string.Format(_translationsService.GetTranslationByKey("validations.lengthBetween"), 6, 60), response);
        }
Пример #5
0
        public void Can_not_create_unit_type_without_invalid_name_lenth()
        {
            var companyModel  = CreateCompany();
            var unitTypeModel = _unitTypeModelGenerator.Get(companyModel);

            unitTypeModel.Name = StringsGenerators.GenerateString(105);
            var response = _unitTypeService.Create(unitTypeModel);

            Assert.IsFalse(response.IsValid);
            AssertValidationErrorIsInList(string.Format(_translationsService.GetTranslationByKey("validations.lessThan"), 100), response);
        }
Пример #6
0
        public void Can_not_create_utility_with_invalid_description_lenth()
        {
            var companyModel = CreateCompany();
            var utilityModel = _utilityModelGenerator.Get(companyModel);

            utilityModel.Description = StringsGenerators.GenerateString(205);
            var response = _utilitySerivce.Create(utilityModel);

            Assert.IsFalse(response.IsValid);
            AssertValidationErrorIsInList(string.Format(_translationsService.GetTranslationByKey("validations.lessThan"), 200), response);
        }
Пример #7
0
        public void Can_not_create_utility_with_duplicate_Id()
        {
            var companyModel = CreateCompany();
            var utilityModel = _utilityModelGenerator.Get(companyModel);
            var response     = _utilitySerivce.Create(utilityModel);

            response.Data.Name        = StringsGenerators.GenerateString(10);
            response.Data.Description = StringsGenerators.GenerateString(20);
            response = _utilitySerivce.Create(response.Data);

            Assert.IsFalse(response.IsValid);
            Assert.IsTrue(response.Errors.Any(x => x.Message == _translationsService.GetTranslationByKey("validations.duplicateId")));
        }
Пример #8
0
        public CompanyModel Get()
        {
            var model = new CompanyModel
            {
                Name        = StringsGenerators.GenerateString(10),
                Address     = StringsGenerators.GenerateString(100),
                Country     = StringsGenerators.GenerateCountryCode(),
                Description = StringsGenerators.GenerateString(199),
                Email       = StringsGenerators.GenerateEmail(9),
                Phone       = StringsGenerators.GeneratePhoneNumber(9)
            };

            return(model);
        }
Пример #9
0
        public SingleEntityResponse <UserModel> CreateFromCompany(Guid companyId, string login)
        {
            var password = StringsGenerators.GenerateString(8);
            var model    = new UserModel
            {
                Email     = login,
                CompanyId = companyId,
                Password  = PasswordHasher.Hash(password)
            };

            var response = base.Create(model);

            //TODO: this is dirty hack, need to unhash password form db
            model.Password = password;

            if (response.IsValid)
            {
                _eventAggregatorProvider.GetEventAggregator().SendMessage(new UserCreated(model));
            }

            return(response);
        }