コード例 #1
0
        public async Task GetAllMembersOne()
        {
            mockDataLoadingService.Setup(m => m.GetMembersAsync()).ReturnsAsync(new List<Member>() { new Member()});

            LibraryService service = new LibraryService();
            var members = await service.GetAllMembers();

            Assert.AreEqual(1, members.Count);
        }
コード例 #2
0
        public async Task MemberOverdueOnTwoBooksOnlyReturnedOnce()
        {
            Checkout mockCheckout1 = new Checkout()
            {
                UserId = "1",
                BookId = "1",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            Checkout mockCheckout2 = new Checkout()
            {
                UserId = "1",
                BookId = "2",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            Checkout mockCheckout3 = new Checkout()
            {
                UserId = "1",
                BookId = "3",
                CheckInDate = DateTime.Today.AddDays(1)
            };

            mockDataLoadingService.Setup(m => m.GetCheckoutsAsync()).ReturnsAsync(new List<Checkout>() { mockCheckout1, mockCheckout2, mockCheckout3 });
            mockDataLoadingService.Setup(m => m.GetMembersAsync()).ReturnsAsync(new List<Member>() { mockMember1 , mockMember2});
            mockDataLoadingService.Setup(m => m.GetBooksAsync()).ReturnsAsync(new List<Book>() { mockBook1, mockBook2 });

            LibraryService service = new LibraryService();
            var members = await service.GetDelinquentMembers();

            Assert.AreEqual(1, members.Count);
        }
コード例 #3
0
        public async Task GetDelinquintMembersOne()
        {
            Checkout mockCheckout1 = new Checkout()
            {
                UserId = "1",
                BookId = "1",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            mockDataLoadingService.Setup(m => m.GetCheckoutsAsync()).ReturnsAsync(new List<Checkout>() {mockCheckout1});
            mockDataLoadingService.Setup(m => m.GetMembersAsync()).ReturnsAsync(new List<Member>() {mockMember1});
            mockDataLoadingService.Setup(m => m.GetBooksAsync()).ReturnsAsync(new List<Book>() {mockBook1});

            LibraryService service = new LibraryService();
            var members = await service.GetDelinquentMembers();

            Assert.AreEqual(1, members.Count);
        }
コード例 #4
0
        public async Task GetLateChargesWithCharges()
        {
            Checkout mockCheckout1 = new Checkout()
            {
                UserId = "1",
                BookId = "1",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            Checkout mockCheckout2 = new Checkout()
            {
                UserId = "1",
                BookId = "2",
                CheckInDate = DateTime.Today.AddDays(-2)
            };

            Checkout mockCheckout3 = new Checkout()
            {
                UserId = "2",
                BookId = "3",
                CheckInDate = DateTime.Today.AddDays(1)
            };

            mockDataLoadingService.Setup(m => m.GetCheckoutsAsync()).ReturnsAsync(new List<Checkout>() { mockCheckout1, mockCheckout2, mockCheckout3 });
            mockDataLoadingService.Setup(m => m.GetMembersAsync()).ReturnsAsync(new List<Member>() { mockMember1, mockMember2 });
            mockDataLoadingService.Setup(m => m.GetBooksAsync()).ReturnsAsync(new List<Book>() { mockBook1, mockBook2 });

            LibraryService ls = new LibraryService();

            var lateCharges = await ls.GetLateChargesForMember(mockMember1);
            Assert.AreEqual(2, lateCharges.Count);
            Assert.AreEqual(0.30, lateCharges[0].Fee);
            Assert.AreEqual(0.60, lateCharges[1].Fee);

        }
コード例 #5
0
        public void GetAmountOwedForMemberWithTwoLateBooks()
        {
            Checkout mockCheckout1 = new Checkout()
            {
                UserId = "1",
                BookId = "1",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            Checkout mockCheckout2 = new Checkout()
            {
                UserId = "1",
                BookId = "2",
                CheckInDate = DateTime.Today.AddDays(-1)
            };

            Checkout mockCheckout3 = new Checkout()
            {
                UserId = "2",
                BookId = "3",
                CheckInDate = DateTime.Today.AddDays(1)
            };

            mockDataLoadingService.Setup(m => m.GetCheckoutsAsync()).ReturnsAsync(new List<Checkout>() { mockCheckout1, mockCheckout2, mockCheckout3 });
            mockDataLoadingService.Setup(m => m.GetMembersAsync()).ReturnsAsync(new List<Member>() { mockMember1, mockMember2 });
            mockDataLoadingService.Setup(m => m.GetBooksAsync()).ReturnsAsync(new List<Book>() { mockBook1, mockBook2 });

            LibraryService ls = new LibraryService();

            Assert.AreEqual(0.6, ls.GetAmountOwed(mockMember1));
        }