Esempio n. 1
0
        public string AddGradeChange(GradeChange gc)
        {
            var errors = new List<string>();
            var repository = new GradeChangeRepository(this.entities);
            var service = new GradeChangeService(repository);
            service.AddGradeChange(gc, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
Esempio n. 2
0
        public void InsertGradeChageTestError1()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IGradeChangeRepository>();
            var gradeChangeService = new GradeChangeService(mockRepository.Object);
            var gc = new GradeChange { Course_id = -1 };

            //// Act
            gradeChangeService.AddGradeChange(gc, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Esempio n. 3
0
        public void InsertGradeChangeTest()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IGradeChangeRepository>();
            var gradeChangeService = new GradeChangeService(mockRepository.Object);
            var gc = new GradeChange { Course_id = 5 };

            mockRepository.Setup(x => x.AddGradeChange(gc, ref errors));

            //// Act
            gradeChangeService.AddGradeChange(gc, ref errors);
            mockRepository.Verify(mock => mock.AddGradeChange(gc, ref errors), Times.Once());

            mockRepository.VerifyAll();
            //// Assert
            Assert.AreEqual(0, errors.Count);
        }