public void WhenEquipmentExists_ShouldUpdateSuccessfully(int id, string name) { using (var factory = new SqlLiteDbContextFactory()) { using (var context = factory.CreateContext()) { SetupTestData(context); var service = new EquipmentService(context); var equipment = new Equipment() { Id = id, Name = name }; service.Update(equipment); var updatedEquipment = service.FindById(id); Assert.NotNull(updatedEquipment); Assert.Equal(updatedEquipment.Id, id); Assert.Equal(updatedEquipment.Name, name); } } }
public void WhenEquipmentDoesNotExist_ReturnNull(int id) { using (var factory = new SqlLiteDbContextFactory()) { using (var context = factory.CreateContext()) { SetupTestData(context); var service = new EquipmentService(context); var equipment = service.FindById(id); Assert.Null(equipment); } } }
public void WhenEquipmentExists_ShouldDeleteEquipment(int id) { using (var factory = new SqlLiteDbContextFactory()) { using (var context = factory.CreateContext()) { SetupTestData(context); var service = new EquipmentService(context); service.Delete(id); var deletedEquipment = service.FindById(id); Assert.Null(deletedEquipment); } } }