public void ShouldCreatePersons() { // Arrange PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); List<PersonEntity> entities = PersonData.GetItemsForInsert(); repository.ClearCollection(); // Act entities = repository.Create(entities); // Assert Assert.IsNotNull(entities); Assert.AreEqual(2, entities.Count); }
public void ShouldThrowArgumentNullExceptionOnConstructor() { // Act try { PersonRepository repository = new PersonRepository(null); Assert.Fail("This should not happen"); } catch (Exception ex) { // Arrange Assert.IsInstanceOf<ArgumentNullException>(ex); } }
private static void ClearAll() { PersonRepository repository1 = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); ContactRepository repository2 = new ContactRepository(ConfigSettings.MySqlDatabaseConnectionName); EntityRepository repository3 = new EntityRepository(ConfigSettings.MySqlDatabaseConnectionName); OccupationNameRepository repository4 = new OccupationNameRepository(ConfigSettings.MySqlDatabaseConnectionName); EntityTypeRepository repository5 = new EntityTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); ContactTypeRepository repository6 = new ContactTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); TitleRepository repository7 = new TitleRepository(ConfigSettings.MySqlDatabaseConnectionName); AddressTypeRepository repository8 = new AddressTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); AddressRepository repository9 = new AddressRepository(ConfigSettings.MySqlDatabaseConnectionName); GenderTypeRepository repository10 = new GenderTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); repository9.ClearCollection(); repository1.ClearCollection(); repository2.ClearCollection(); repository3.ClearCollection(); repository4.ClearCollection(); repository5.ClearCollection(); repository6.ClearCollection(); repository7.ClearCollection(); repository8.ClearCollection(); repository10.ClearCollection(); }
private static void CreatePerson() { PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); PersonEntity entity = new PersonEntity() { EntityId = _entityEntities[0].Id, OccupationNameId = _occupationNameEntities[0].Id, TitleId = _titleEntities[0].Id, GenderTypeId = _genderTypeEntities[0].Id, SurnamePrefix = "van", Surname = "Riebeeck", MaidenNamePrefix = string.Empty, Nationality = "nl", DateOfBirth = DateTime.UtcNow.AddYears(-34), PlaceOfBirth = "Houten", DeletedDate = DateTime.MinValue }; PersonEntity mEntity = new PersonEntity() { EntityId = _entityEntities[1].Id, OccupationNameId = _occupationNameEntities[1].Id, TitleId = _titleEntities[1].Id, GenderTypeId = _genderTypeEntities[1].Id, SurnamePrefix = string.Empty, Surname = "Stel", MaidenNamePrefix = "", Nationality = "BL", DateOfBirth = DateTime.UtcNow.AddYears(-37), PlaceOfBirth = "Zeist", DeletedDate = DateTime.MinValue }; entity = repository.Create(entity); mEntity = repository.Create(mEntity); _personEntities.Add(entity); _personEntities.Add(mEntity); }
public static PersonEntity CreatePerson() { PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); PersonEntity entity = PersonData.GetItemForInsert(); //repository.ClearCollection(); entity = repository.Create(entity); return entity; }
public static void ClearPerson() { PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); repository.ClearCollection(); }
public void ShouldReadPersonWithId() { // Arrange PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); PersonEntity entity = PersonData.GetItemForInsert(); repository.ClearCollection(); // Act entity = repository.Create(entity); // Act var actual = repository.Read(entity.Id); // Assert Assert.AreEqual(entity.EntityId, actual.EntityId); }
public void Init() { _repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); }
public void ShouldUpdatePerson() { // Arrange PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName); PersonEntity entity = PersonData.GetItemForInsert(); repository.ClearCollection(); entity = repository.Create(entity); entity.Nationality = "NL"; // Act PersonEntity actual = repository.Update(entity); // Assert Assert.AreEqual(entity.Nationality, actual.Nationality); }