public void CreateCheckedInHolding() { aCheckedInHolding = new Holding { Classification = "ABC", CopyNumber = 1 }; aCheckedInHolding.CheckIn(DateTime.Now, someValidBranchId); }
public static Holding SaveCheckedInHoldingWithClassification(LibraryContext context, string classification) { var holding = new Holding { Classification = classification }; holding.CheckIn(DateTime.Now, 1); context.Holdings.Add(holding); context.SaveChanges(); return(holding); }
public void CheckInAnswersZeroDaysLateWhenReturnedBeforeDueDate() { var holding = new Holding { Classification = "X", BranchId = 1, CopyNumber = 1 }; holding.CheckOut(DateTime.Now, PatronId, CheckoutPolicies.BookCheckoutPolicy); var date = holding.DueDate.Value.AddDays(-1); int branchId = 2; holding.CheckIn(date, branchId); Assert.Equal(0, holding.DaysLate()); }
public void DaysLateCalculatedWhenReturnedAfterDueDate() { var holding = new Holding { Classification = "X", BranchId = 1, CopyNumber = 1 }; holding.CheckOut(DateTime.Now, PatronId, CheckoutPolicies.BookCheckoutPolicy); var date = holding.DueDate.Value.AddDays(2); var branchId = 2; holding.CheckIn(date, branchId); Assert.Equal(2, holding.DaysLate()); }
public void CheckInAnswersZeroDaysLateWhenReturnedOnDueDate() { var holding = new Holding { Classification = "X", BranchId = 1, CopyNumber = 1 }; holding.CheckOut(DateTime.Now, PatronId, CheckoutPolicies.BookCheckoutPolicy); var dueDate = holding.DueDate.Value; int brId = 2; holding.CheckIn(dueDate, brId); Assert.That(holding.DaysLate(), Is.EqualTo(0)); }
public void CheckIn() { var holding = new Holding { Classification = "X", BranchId = 1, CopyNumber = 1 }; // check out movie holding.CheckOut(DateTime.Now, PatronId, CheckoutPolicies.BookCheckoutPolicy); var tomorrow = DateTime.Now.AddDays(1); const int newBranchId = 2; holding.CheckIn(tomorrow, newBranchId); Assert.IsFalse(holding.IsCheckedOut); Assert.That(holding.HeldByPatronId, Is.EqualTo(Holding.NoPatron)); Assert.That(holding.CheckOutTimestamp, Is.Null); Assert.That(holding.BranchId, Is.EqualTo(newBranchId)); // day after now Assert.That(holding.LastCheckedIn, Is.EqualTo(tomorrow)); }
public void CheckIn() { var holding = new Holding("X", 1) { BranchId = 1 }; holding.CheckOut(DateTime.Now, PatronId, CheckoutPolicies.BookCheckoutPolicy); var tomorrow = DateTime.Now.AddDays(1); const int newBranchId = 2; holding.CheckIn(tomorrow, newBranchId); Assert.IsFalse(holding.IsCheckedOut); Assert.That(holding.HeldByPatronId, Is.EqualTo(Holding.NoPatron)); Assert.That(holding.CheckOutTimestamp, Is.EqualTo(DateTime.MinValue)); Assert.That(holding.BranchId, Is.EqualTo(newBranchId)); Assert.That(holding.LastCheckedIn, Is.EqualTo(tomorrow)); }
public void Co() { var holding = new Holding { Classification = "", CopyNumber = 1, BranchId = 1 }; Assert.False(holding.IsCheckedOut); var now = DateTime.Now; var policy = CheckoutPolicies.BookCheckoutPolicy; holding.CheckOut(now, PatronId, policy); Assert.True(holding.IsCheckedOut); Assert.Equal(policy.Id, holding.CheckoutPolicy.Id); Assert.Equal(PatronId, holding.HeldByPatronId); var dueDate = now.AddDays(policy.MaximumCheckoutDays()); Assert.Equal(dueDate, holding.DueDate); Assert.Equal(Branch.CheckedOutId, holding.BranchId); // checking in var tomorrow = DateTime.Now.AddDays(1); const int newBranchId = 2; holding.CheckIn(tomorrow, newBranchId); Assert.False(holding.IsCheckedOut); Assert.Equal(Holding.NoPatron, holding.HeldByPatronId); Assert.Null(holding.CheckOutTimestamp); Assert.Equal(newBranchId, holding.BranchId); // day after now Assert.Equal(tomorrow, holding.LastCheckedIn); }
public virtual void CheckIn(Holding holding, int branchId) { holding.CheckIn(TimeService.Now, branchId); Update(holding); }