Esempio n. 1
0
        public void GetItems_TwoItems_ReturnTwoItems()
        {
            // Arrange.
            var candidateTask = new DemoLab.Models.ExerciseManagement.CandidateTask {
                Id = 1
            };
            var candidateTest = new DemoLab.Models.ExerciseManagement.CandidateTest {
                Id = 2
            };
            var exercises = new DemoLab.Models.ExerciseManagement.CandidateExercise[] { candidateTask, candidateTest };

            _exercisePoolMock.Setup(pool => pool.GetActiveExerciseSet()).Returns(exercises);

            var candidateTaskResult = new CandidateTaskResult
            {
                CreatorId         = Guid.Empty,
                CandidateExercise = new DemoLab.Data.Access.ExerciseManagement.CandidateTask {
                    Id = 1
                }
            };

            var candidateTestResult = new CandidateTestResult
            {
                CreatorId         = Guid.Empty,
                CandidateExercise = new DemoLab.Data.Access.ExerciseManagement.CandidateExercise {
                    Id = 2
                }
            };

            var fakeTaskSet = new FakeEntitySet <CandidateTaskResult>(new List <CandidateTaskResult> {
                candidateTaskResult
            });
            var fakeTestSet = new FakeEntitySet <CandidateTestResult>(new List <CandidateTestResult> {
                candidateTestResult
            });

            _exerciseContextMock.SetupGet(t => t.CandidateTaskResults).Returns(fakeTaskSet);
            _exerciseContextMock.SetupGet(t => t.CandidateTestResults).Returns(fakeTestSet);

            _service = new ExerciseService(
                _exerciseContextMock.Object,
                _exercisePoolMock.Object,
                _testAssemblyContextMock.Object);

            // Act.
            var result = _service.GetCandidateExerciseList(applicationUserId: Guid.NewGuid());

            // Assert.
            Assert.AreEqual(2, result.Count());
        }
Esempio n. 2
0
        public void GetItems_ZeroSet_ReturnsEmptyCollection()
        {
            // Arrange.
            var exercises = new DemoLab.Models.ExerciseManagement.CandidateExercise[] { };

            _exercisePoolMock.Setup(pool => pool.GetActiveExerciseSet()).Returns(exercises);

            var fakeTaskSet = new FakeEntitySet <CandidateTaskResult>(new List <CandidateTaskResult>());
            var fakeTestSet = new FakeEntitySet <CandidateTestResult>(new List <CandidateTestResult>());

            _exerciseContextMock.SetupGet(t => t.CandidateTaskResults).Returns(fakeTaskSet);
            _exerciseContextMock.SetupGet(t => t.CandidateTestResults).Returns(fakeTestSet);

            _service = new ExerciseService(
                _exerciseContextMock.Object,
                _exercisePoolMock.Object,
                _testAssemblyContextMock.Object);

            // Act.
            var result = _service.GetCandidateExerciseList(applicationUserId: Guid.NewGuid());

            // Assert.
            Assert.AreEqual(0, result.Count());
        }
Esempio n. 3
0
 public void GetItems_GuidEmptyArg_ThrowsException()
 {
     Assert.That(
         () => _service.GetCandidateExerciseList(Guid.Empty), Throws.TypeOf <ArgumentException>());
 }