private void RemoveSet(Set set, Show show, ref SetService setService) { set.Deleted = true; set.DeletedDate = DateTime.Now; setService.Delete(set); short?setNumber = 1; var setList = show.Sets.OrderBy(x => x.SetNumber).Where(x => x.SetId != set.SetId); foreach (var s in setList) { s.SetNumber = setNumber; setNumber++; } }
public void Delete() { // Arrange var idForRemove = 2; var currentItemsCount = _sets.Count; _mock.Setup(s => s.Delete(idForRemove)).Callback <int>(id => { var itemForRemove = _sets.Where(set => set.Id == id).FirstOrDefault(); _sets.Remove(itemForRemove); }); // Act var result = _setService.Delete(idForRemove); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IOperationResult)); Assert.AreEqual(_sets.Count, currentItemsCount - 1); Assert.IsTrue(result.Succeed); Assert.IsFalse(_sets.Any(set => set.Id == idForRemove)); }