public void TearDownRelatedData() { RoomHoursRepository repository = new RoomHoursRepository(ConfigSettings.MySqlDatabaseConnectionName); repository.ClearCollection(); CostCentreRepository costCentreRepository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); costCentreRepository.ClearCollection(); HourTypeRepository hourTypeRepository = new HourTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); hourTypeRepository.ClearCollection(); }
public void ShouldCreateCostCentre() { // Arrange CostCentreRepository repository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity entity = HoursData.GetCostCentreForInsert(); repository.ClearCollection(); // Act entity = repository.Create(entity); // Assert Assert.IsNotNull(entity); Assert.AreNotEqual(0, entity.Id); }
public void ShouldCreateCostCentres() { // Arrange CostCentreRepository repository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); List<CostCentreEntity> entities = HoursData.GetCostCentresForInsert(); repository.ClearCollection(); // Act entities = repository.Create(entities); // Assert Assert.IsNotNull(entities); Assert.AreEqual(2, entities.Count); }
public void ShouldThrowArgumentNullExceptionOnConstructor() { // Act try { CostCentreRepository repository = new CostCentreRepository(null); Assert.Fail("This should not happen"); } catch (Exception ex) { // Arrange Assert.IsInstanceOf<ArgumentNullException>(ex); } }
public void SetUpRelatedData() { RoomHoursRepository repository = new RoomHoursRepository(ConfigSettings.MySqlDatabaseConnectionName); repository.ClearCollection(); CostCentreRepository costCentreRepository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity costCentreEntity = HoursData.GetCostCentreForInsert(); costCentreRepository.ClearCollection(); _costCentre = costCentreRepository.Create(costCentreEntity); HourTypeRepository hourTypeRepository = new HourTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); HourTypeEntity hourTypeEntity = HoursData.GetHourTypeForInsert(); hourTypeRepository.ClearCollection(); _hourType = hourTypeRepository.Create(hourTypeEntity); }
public void ShouldReadCostCentreWithId() { // Arrange CostCentreRepository repository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity entity = HoursData.GetCostCentreForInsert(); repository.ClearCollection(); // Act entity = repository.Create(entity); // Act var actual = repository.Read(entity.Id); // Assert Assert.AreEqual(entity.Code, actual.Code); }
public static void CreateCostCentres() { CostCentreRepository repository = new CostCentreRepository(ConfigSettings.HoursDatabaseConnectionName); var costCentres = repository.Read(); if (!CheckCostCentre(costCentres, "ENGI")) { repository.Create(new CostCentreEntity { LookupCode = "ENGI", Code = "01", Description = "Engineering", DeletedDate = DateTime.MinValue }); } if (!CheckCostCentre(costCentres, "PROD")) { repository.Create(new CostCentreEntity { LookupCode = "PROD", Code = "02", Description = "Werkplaats", DeletedDate = DateTime.MinValue }); } if (!CheckCostCentre(costCentres, "PNTG")) { repository.Create(new CostCentreEntity { LookupCode = "PNTG", Code = "03", Description = "Spuiterij", DeletedDate = DateTime.MinValue }); } if (!CheckCostCentre(costCentres, "ONBR")) { repository.Create(new CostCentreEntity { LookupCode = "ONBR", Code = "04", Description = "Boord", DeletedDate = DateTime.MinValue }); } }
public void ShouldUpdateCostCentre() { // Arrange CostCentreRepository repository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity entity = HoursData.GetCostCentreForInsert(); repository.ClearCollection(); entity = repository.Create(entity); entity.Code = "87"; // Act CostCentreEntity actual = repository.Update(entity); // Assert Assert.AreEqual(entity.Code, actual.Code); }
public void ShouldDeleteCostCentre() { // Arrange CostCentreRepository repository = new CostCentreRepository(ConfigSettings.MySqlDatabaseConnectionName); CostCentreEntity entity = HoursData.GetCostCentreForInsert(); repository.ClearCollection(); entity = repository.Create(entity); // Act CostCentreEntity actual = repository.Delete(entity); // Assert Assert.AreNotEqual(actual.DeletedDate,DateTime.MinValue); }