コード例 #1
0
        public void TestCredits()
        {
            // Using Moq for testing individual components. we can repeat this test
            // for all other components.

            var                mockCredits  = new Mock <IChecks>();
            IRepository        IRepository  = new Repository.Repository();
            List <Requirement> requirements = IRepository.GetRequirements();
            List <Course>      courses      = GetCourseData();

            mockCredits.Setup(credit => credit.CheckAllCreditsPassed(It.IsAny <List <Requirement> >(), It.IsAny <List <Course> >())).Returns(true);
            IChecks check  = new Checks();
            bool    result = check.CheckAllCreditsPassed(requirements, courses);

            // There was a logical error to test passed or not. for example what happen if
            // average is more than 50 but one or more mourses are less than 50?
            // Here we make sure that each student has passed all credits.
            Assert.IsTrue(result);
        }