Ejemplo n.º 1
0
        public void CreateEval_EmptyEntity_ThrowsMissingInfoException()
        {
            var testClass  = InteractorFactory.Create_EvaluationInteractor();
            var testEntity = new EvaluationEntity();

            Should.Throw <MissingInfoException>(() => testClass.CreateEvaluation(testEntity));
        }
Ejemplo n.º 2
0
        public void GetByCourseId_EmptyGuid_ThrowsBadInfoException()
        {
            var testClass = InteractorFactory.Create_EvaluationInteractor();
            var testGuid  = Guid.Empty;

            Should.Throw <BadInfoException>(() => testClass.GetEvaluationsByCourseId(testGuid));
        }
Ejemplo n.º 3
0
        public void GetById_EmptyGuid_ThrowsObjectNotFound()
        {
            var testClass = InteractorFactory.Create_EvaluationInteractor();
            var testGuid  = Guid.Empty;

            Should.Throw <ObjectNotFoundException>(() => testClass.GetEvaluation(testGuid));
        }
Ejemplo n.º 4
0
        public void UpdateEvaluation_NewObject_ThrowsObjectNotFound()
        {
            var testClass = InteractorFactory.Create_EvaluationInteractor();

            var testScore = EvaluationFactory.Create_EvaluationEntity_ValidMinimum();

            Should.Throw <ObjectNotFoundException>(() => testClass.UpdateEvaluation(testScore));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        public void UpdateEvaluation_ValidObject_UpdatesScore()
        {
            var evalGuid           = Guid.NewGuid();
            var testList           = EvaluationFactory.Create_ListValidEvalEntities();
            var testRepo           = new MockRepository <EvaluationEntity>(testList);
            var testClass          = InteractorFactory.Create_EvaluationInteractor(testRepo);
            var evaluationToUpdate = testRepo.GetAll().First();

            var updatedEvaluation = new EvaluationEntity {
                Id = evaluationToUpdate.Id, Weight = .2, DropLowest = true, NumberOfScores = 1
            };

            testClass.UpdateEvaluation(updatedEvaluation);

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

            result.LastModified.ShouldNotBeSameAs(evaluationToUpdate.LastModified);
            result.Weight.ShouldBe(.2);
            result.DropLowest.ShouldBe(true);
            result.NumberOfScores.ShouldBe(1);
        }
Ejemplo n.º 10
0
        public void DeleteEvaluation_ValidGuid_RemovesEvaluation()
        {
            var deleteEvalId = Guid.NewGuid();
            var remainEvalId = Guid.NewGuid();
            var courseId     = Guid.Parse("b59009e4-3f12-4eaf-a82c-bfaa6371b1a4");
            var testList     =
                new List <EvaluationEntity>
            {
                EvaluationFactory.Create_EvaluationEntity_ValidMinimum_CustomId(deleteEvalId),
                EvaluationFactory.Create_EvaluationEntity_ValidMinimum_CustomId(remainEvalId)
            };

            var testRepo  = new MockRepository <EvaluationEntity>(testList);
            var testClass = InteractorFactory.Create_EvaluationInteractor(testRepo);

            testClass.DeleteEvaluation(deleteEvalId);

            var result = testClass.GetEvaluationsByCourseId(courseId);

            result.Count.ShouldBe(1);
        }