public UtilityModel Get() { return(new UtilityModel() { Name = StringsGenerators.GenerateString(10), Description = StringsGenerators.GenerateString(60), }); }
public UnitTypeModel Get() { var model = new UnitTypeModel(); model.Description = StringsGenerators.GenerateString(199); model.Name = StringsGenerators.GenerateString(10); return(model); }
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); }
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); }
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); }
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); }
public void Can_not_create_company_with_invalid_phone_number() { var companyModel = _companyGenerator.Get(); companyModel.Phone = StringsGenerators.GenerateInvalidPhoneNumber(9); var response = _companyService.Create(companyModel); Assert.IsFalse(response.IsValid); Assert.IsTrue(response.Errors.Any(x => x.Message == _translationsService.GetTranslationByKey("validations.invalidPhone"))); }
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"))); }
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); }
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); }