示例#1
0
        public void TC1_4()
        {
            //Arrange
            var loanRepos = new Mock <ILoanRepos <Loan> >();
            var cardRepos = new Mock <ICardRepos <Card> >();
            var userRepos = new Mock <IUserRepos <Person> >();

            loanRepos.Setup(x => x.CheckForStatusOnCopy(It.IsAny <Copy>())).Returns(true);
            loanRepos.Setup(x => x.Create(It.IsAny <Loan>())).Returns((Loan loan) => loan);
            cardRepos.Setup(x => x.Get(It.IsAny <Card>())).Returns(Person.Card);
            userRepos.Setup(x => x.GetUserByCardID(1)).Returns(Person);
            userRepos.Setup(x => x.GetLibrarianById(1)).Returns(Lib);
            var lc = new LoanLogic(loanRepos.Object, cardRepos.Object, userRepos.Object);

            //Act
            var createdLoan = lc.CreateLoan(1, 5, 0, 0, 0, 0, 1);

            //Assert
            Assert.True(createdLoan.StartDate == DateTime.Now.Date);
        }
示例#2
0
        public void TC3_3()
        {
            //Arrange
            Loan loan      = new Loan();
            var  loanRepos = new Mock <ILoanRepos <Loan> >();
            var  cardRepos = new Mock <ICardRepos <Card> >();
            var  userRepos = new Mock <IUserRepos <Person> >();

            loanRepos.Setup(x => x.CheckForStatusOnCopy(It.IsAny <Copy>())).Returns(false);
            loanRepos.Setup(x => x.Create(loan)).Returns(loan);
            cardRepos.Setup(x => x.Get(It.IsAny <Card>())).Returns(Person.Card);
            userRepos.Setup(x => x.GetUserByCardID(1)).Returns(Person);
            userRepos.Setup(x => x.GetLibrarianById(1)).Returns(Lib);
            var lc = new LoanLogic(loanRepos.Object, cardRepos.Object, userRepos.Object);

            //Act
            var createdLoan = lc.CreateLoan(1, 5, 0, 0, 0, 0, 1);

            //Assert
            Assert.NotNull(createdLoan.ErrorMessage);
        }