public async Task SignUp_Publish_Subscribe_WithinLimit_True()
        {
            var student = AddNewStudent();
            var course  = AddNewCourse(2);

            Assert.NotEqual(0, student.Id);
            Assert.NotEqual(0, course.Id);
            var cancelationSource = new CancellationTokenSource();
            await _courseStudentRepo.SignupPublishAsync(courseId : course.Id, studentId : student.Id, cancellationToken : cancelationSource.Token);

            var isSignedUpSubscribed = await _courseStudentRepo.SignupSubscribeAsync();

            Assert.True(isSignedUpSubscribed);
        }
Ejemplo n.º 2
0
        [ResponseCache(CacheProfileName = StringMessages.DefaultCacheProfile)] //VaryByHeader = "User-Agent", Duration = 30)]
        public async Task <ActionResult> SigupAsync(int courseId, int studentId, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                await _courseStudentRepo.SignupPublishAsync(courseId : courseId, studentId : studentId, cancellationToken : cancellationToken);

                var isSignedUp = await _courseStudentRepo.SignupSubscribeAsync();

                if (isSignedUp)
                {
                    return(Ok());
                }
                return(BadRequest(Internal_Server_Error));
            }
            catch (CourseCapacityFullException e)
            {
                return(BadRequest(HandleCourseCapacityFullException(courseId, studentId)));
            }
        }