예제 #1
0
        public void DeleteCourse_EvalsPresent_DeletesEvals()
        {
            var testCourseId = Guid.NewGuid();
            var testEvals    = new List <EvaluationEntity>
            {
                EvaluationFactory.Create_EvaluationEntity_ValidMinimum(testCourseId)
            };

            var testEvalRepo   = new MockRepository <EvaluationEntity>(testEvals);
            var evalService    = TestDatas.Evaluations.ServiceFactory.Create_EvaluationService();
            var evalInteractor = TestDatas.Evaluations.InteractorFactory.Create_EvaluationInteractor();

            evalInteractor.Repo = testEvalRepo;
            evalService.EvaluationInteractor = evalInteractor;
            evalService.ScoreInteractor      = new MockScoreInteractor();
            var testClass = ServiceFactory.Create_MockInteractor();

            testClass.EvaluationService = evalService;

            var result       = testClass.DeleteCourse(testCourseId);
            var resultScores = testClass.EvaluationService.GetEvaluationsForCourse(testCourseId);

            result.GetType().ShouldNotBe(typeof(ErrorDomainModel));
            resultScores.Count.ShouldBe(0);
        }
예제 #2
0
        public void UpdateEvaluation_NewObject_ThrowsObjectNotFound()
        {
            var testClass = InteractorFactory.Create_EvaluationInteractor();

            var testScore = EvaluationFactory.Create_EvaluationEntity_ValidMinimum();

            Should.Throw <ObjectNotFoundException>(() => testClass.UpdateEvaluation(testScore));
        }
예제 #3
0
        public EvaluationEntity GetEvaluation(Guid evaluationId)
        {
            if (evaluationId.Equals(Guid.Empty))
            {
                throw new ObjectNotFoundException();
            }

            return(EvaluationFactory.Create_EvaluationEntity_ValidMinimum(evaluationId));
        }
예제 #4
0
        public void CreateEval_ValidModel_ResultNotNull()
        {
            var testClass = InteractorFactory.Create_EvaluationInteractor();
            var testModel = EvaluationFactory.Create_EvaluationEntity_ValidMinimum();

            var result = testClass.CreateEvaluation(testModel);

            result.ShouldNotBeNull();
            result.ShouldNotBe(Guid.Empty);
        }
예제 #5
0
        public void GetById_ValidGuid_ReturnsTestEntity()
        {
            var testRepo   = new Mocks.MockRepository <EvaluationEntity>();
            var testEntity = EvaluationFactory.Create_EvaluationEntity_ValidMinimum(Guid.NewGuid());

            testRepo.Update(testEntity);
            var testClass = InteractorFactory.Create_EvaluationInteractor(testRepo);

            var result = testClass.GetEvaluation(testEntity.Id);

            result.ShouldBe(testEntity);
        }
예제 #6
0
        public void CreateEval_DuplicateName_ThrowsObjectAlreadyExists()
        {
            var testRepo     = new MockRepository <EvaluationEntity>();
            var existingEval = EvaluationFactory.Create_EvaluationEntity_ValidMinimum_CustomId(Guid.NewGuid());

            testRepo.Update(existingEval);

            var testEval = EvaluationFactory.Create_EvaluationEntity_ValidMinimum();

            var testClass = InteractorFactory.Create_EvaluationInteractor(testRepo);

            Should.Throw <ObjectAlreadyExistsException>(() => testClass.CreateEvaluation(testEval));
        }
예제 #7
0
        public void GetByCourseId_ValidCourseId_ReturnsTwoEvals()
        {
            var testRepo    = new MockRepository <EvaluationEntity>();
            var testGuid    = Guid.NewGuid();
            var testEvalOne = EvaluationFactory.Create_EvaluationEntity_ValidMinimum(testGuid);
            var testEvalTwo = EvaluationFactory.Create_EvaluationEntity_ValidMinimum(testGuid);

            testRepo.Create(testEvalOne);
            testRepo.Create(testEvalTwo);

            var testClass = InteractorFactory.Create_EvaluationInteractor(testRepo);

            var result = testClass.GetEvaluationsByCourseId(testGuid);

            result.Count.ShouldBe(2);
        }
예제 #8
0
        public List <EvaluationEntity> GetEvaluationsByCourseId(Guid courseId)
        {
            if (courseId.Equals(Guid.Empty))
            {
                throw new BadInfoException();
            }

            var listOfEvaluations = new List <EvaluationEntity>
            {
                EvaluationFactory.Create_EvaluationEntity_ValidMinimum(courseId),
                EvaluationFactory.Create_EvaluationEntity_ValidMinimum(courseId)
            };


            return(listOfEvaluations);
        }