Esempio n. 1
0
        public async Task ShouldSayUnKnownIfFileDoesNotExists()
        {
            _courseItemRepository.Setup(x => x.GetQueryable())
            .Returns(new List <CourseItem>().AsQueryable().BuildMock().Object);

            var res = await _handler.Handle(new HasAccessToFileQuery(0, "non-existing-file-path"),
                                            CancellationToken.None);

            Assert.Equal(res.Status, ResponseStatus.UnKnown);
        }
        public async Task ShouldSayUnKnownIfFileDoesNotExists()
        {
            var filePath = "path-to-some-secured-file";

            _examRepository.Setup(x => x.GetQueryable())
            .Returns(new List <ExamSampleFile>().AsQueryable().BuildMock().Object);
            var handler = new HasAccessToFileQueryHandler(_studentBoughtItems.Object, _examRepository.Object);
            var res     = await handler.Handle(new HasAccessToFileQuery(0, filePath), CancellationToken.None);

            Assert.Equal(res.Status, ResponseStatus.UnKnown);
        }
        public async Task ShouldNotAllowNotBoughtItemForUser()
        {
            var  filePath  = "path-to-some-secured-file";
            long studentId = 2;

            _examRepository.Setup(x => x.GetQueryable())
            .Returns(new List <ExamSampleFile>
            {
                new ExamSampleFile
                {
                    FilePath = filePath
                }
            }.AsQueryable().BuildMock().Object);
            _studentBoughtItems.Setup(x => x.GetQueryable()).Returns(new List <StudentExamSampleMapping>().AsQueryable().BuildMock().Object);
            var handler = new HasAccessToFileQueryHandler(_studentBoughtItems.Object, _examRepository.Object);
            var res     = await handler.Handle(new HasAccessToFileQuery(studentId, filePath), CancellationToken.None);

            Assert.Equal(res.Status, ResponseStatus.Fail);
        }