예제 #1
0
 public void CreateCheckedInHolding()
 {
     aCheckedInHolding = new Holding {
         Classification = "ABC", CopyNumber = 1
     };
     aCheckedInHolding.CheckIn(DateTime.Now, someValidBranchId);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }
예제 #5
0
        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));
        }
예제 #6
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));
        }
예제 #7
0
        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));
        }
예제 #8
0
        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);
        }
예제 #9
0
 public virtual void CheckIn(Holding holding, int branchId)
 {
     holding.CheckIn(TimeService.Now, branchId);
     Update(holding);
 }