public async Task Delete_HasNotActiveRents_ShouldDelete() { var oldCount = Subscribers.Count; var subscriber = Subscribers.First(); if (!subscriber.Rents.Any()) { subscriber.Rents.Add(new Rent(null, null) { IsActive = false }); } var returnVal = await SubscribersService.Delete(subscriber.Id); #region Assert returnVal Assert.That(returnVal.Lastname, Is.EqualTo(subscriber.Lastname)); Assert.That(returnVal.Firstname, Is.EqualTo(subscriber.Firstname)); Assert.That(returnVal.Middlename, Is.EqualTo(subscriber.Middlename)); Assert.That(returnVal.IsDeleted, Is.True); #endregion Assert.That(Subscribers.Count, Is.EqualTo(oldCount)); var deletedSubscriber = Subscribers.SingleOrDefault(x => x.Id == subscriber.Id); Assert.That(deletedSubscriber, Is.Not.Null); Assert.That(deletedSubscriber.IsDeleted, Is.True); }
public void Delete_ShouldThrownSubscriberHasActiveRentsException() { var subscriber = Subscribers.First(); if (!subscriber.Rents.Any()) { subscriber.Rents.Add(new Rent(null, null) { IsActive = true }); } Assert.Throws <SubscriberHasActiveRentsException>(async() => await SubscribersService.Delete(subscriber.Id)); }
public async Task Delete_ShouldDeleted() { var oldCount = Subscribers.Count; var subscriber = Subscribers.First(); subscriber.Rents.Clear(); var returnVal = await SubscribersService.Delete(subscriber.Id); #region Assert returnVal Assert.That(returnVal.Lastname, Is.EqualTo(subscriber.Lastname)); Assert.That(returnVal.Firstname, Is.EqualTo(subscriber.Firstname)); Assert.That(returnVal.Middlename, Is.EqualTo(subscriber.Middlename)); #endregion Assert.That(Subscribers.Count, Is.EqualTo(oldCount - 1)); Assert.That(Subscribers.SingleOrDefault(x => x.Id == subscriber.Id), Is.Null); }