public UserEntity GenerateUser() { UserEntity user = new UserEntity(); user.Login = _repository.GetRandomLogin(); IdentityInfo identityName = _repository.GetRandomName(); user.Name = identityName.Identity; user.Surname = _repository.GetRandomSurname(identityName.Gender); bool isPatronymicExist = _random.Next(100) != 0; if (isPatronymicExist) user.Patronymic = _repository.GetRandomPatronymic(identityName.Gender); user.Password = _random.Next(1000, 10000).ToString(); user.Email = string.Format(@"{0}@{1}", user.Login, _repository.GetRandomMailDomain()); int year = _random.Next(2010, 2017); int month = _random.Next(1, 13); int day = _random.Next(1, 29); if (year == 2016 && month > 2) month = 2; user.RegistrationDate = new DateTime(year, month, day); return user; }
public string GetValueLine(UserEntity entity) { string registrationDate = entity.RegistrationDate.ToString("yyyyMMdd"); string result = string.Format("('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", entity.Name, entity.Surname, entity.Patronymic, entity.Email, entity.Login, entity.Password, registrationDate); return result; }
public void GenerateUser_GetValueLine() { UserEntity user = new UserEntity() { Name = "Петр", Surname = "Петров", Patronymic = "Петрович", Email = "*****@*****.**", Login = "******", Password = "******", RegistrationDate = new DateTime(2016, 1, 1) }; IScriptGenerator generator = new ScriptGenerator(new RepositoryMock()); string expectedResult = @"VALUES ('Петр', 'Петров', 'Петрович', '*****@*****.**', 'petr', '12345', '20160101')"; string result = generator.GetValueLine(user); Assert.That(result, Is.EqualTo(expectedResult)); }