public void GetBooksIssued_Eception()
        {
            Mock <IDatabase>                    mock           = new Mock <IDatabase>();
            Mock <DashboardTable>               mockdash       = new Mock <DashboardTable>();
            DashboardTable                      dashboardtable = new DashboardTable(mock.Object);
            Dictionary <string, string>         parameter      = new Dictionary <string, string>();
            List <Dictionary <string, string> > result         = new List <Dictionary <string, string> >();

            parameter.Add("Blank", "10");
            parameter.Add("Book_ID", "9");
            parameter.Add("BookStatus", "Renewed");
            parameter.Add("Member_ID", "25");
            parameter.Add("Due_Date", "2018-07-22 17:35:23");
            parameter.Add("Date_of_issue", "2018-07-22 17:35:23");
            result.Add(parameter);
            BookTranscation book = new BookTranscation();

            book.SetMemberID(1);
            book.SetBookID(2);
            book.SetBookStatus("Issued");
            book.SetDateofissue(DateTime.Now);
            book.SetDueDate(DateTime.Now);
            mock.Setup(x => x.Query(It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(result);
            //mockdash.Setup(x => x.GetActiveBookTranscation()).Returns(book);
            Assert.IsInstanceOfType(dashboardtable.GetBooksIssued(), typeof(IEnumerable <BookTranscation>));
        }
Beispiel #2
0
        public void Valid_ReturnTranscation()
        {
            Mock <IDatabase>                    mock            = new Mock <IDatabase>();
            BookController                      bookcontroller  = new BookController(mock.Object);
            Dictionary <string, string>         parameter       = new Dictionary <string, string>();
            List <Dictionary <string, string> > result          = new List <Dictionary <string, string> >();
            BookTranscation                     booktranscation = new BookTranscation();

            booktranscation.SetTranscationID(0);
            booktranscation.SetMemberID(0);
            booktranscation.SetBookID(0);
            booktranscation.SetBookStatus("available");
            booktranscation.SetDateofissue(new DateTime(2018, 07, 22));
            booktranscation.SetDueDate(new DateTime(2018, 07, 22));
            mock.Setup(x => x.Query(It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(result);
            parameter.Add("Transcation_ID", "11");
            parameter.Add("Member_ID", "25");
            parameter.Add("Book_ID", "123");
            parameter.Add("BookStatus", "Available");
            parameter.Add("Due_Date", "2018, 07, 22");
            parameter.Add("Date_of_issue", "2018, 07, 22");
            result.Add(parameter);
            var bookreturntranscation = bookcontroller.RenewTransaction("4081") as RedirectToRouteResult;

            Assert.IsNotNull(bookreturntranscation);
        }
        public void Insert()
        {
            Mock <IDatabase> mock = new Mock <IDatabase>();

            mock.Setup(x => x.Execute(It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(1);
            BookTranscationTable booktable = new BookTranscationTable(mock.Object);
            BookTranscation      book      = new BookTranscation();

            book.SetMemberID(1);
            book.SetBookID(2);
            book.SetBookStatus("Renewed");
            book.SetDateofissue(DateTime.Now);
            book.SetDueDate(DateTime.Now);
            int result = booktable.Insert(book);

            Assert.AreEqual(1, result);
        }
Beispiel #4
0
        public void IssueBook_invalidBookID()
        {
            Mock <IDatabase> mock = new Mock <IDatabase>();

            mock.Setup(x => x.Execute(It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(1);
            BookController bookcontroller = new BookController(mock.Object);
            var            book           = new BookTranscation();

            book.SetTranscationID(11);
            book.SetMemberID(25);
            book.SetBookID(3);
            book.SetBookStatus("available");
            book.SetDateofissue(new DateTime(2018, 07, 22));
            book.SetDueDate(new DateTime(2018, 07, 22));
            var result = bookcontroller.IssueBook(book) as ViewResult;

            Assert.IsNotNull(result);
        }