예제 #1
0
        public void PutProgressWhenAlreadyDoingAssignmentIsForbidden()
        {
            SetupControllerForTests(_controller);
            Assignment assignment = new Assignment {
                Id = 2, MaxSolveTime = 1000
            };

            Progress progress = new Progress {
                Assignment = assignment, Id = 2, Participant = _participant
            };
            var result = _controller.Put(2, progress);

            Assert.AreEqual(HttpStatusCode.Forbidden, result.StatusCode);
        }
예제 #2
0
        public void PutProgressReturnsCreatedStatusCode()
        {
            _contextMock = new Mock <IDbContext>();
            var list = CreateSampleData(3);

            _contextMock.Setup(m => m.Assignments).Returns(list);
            _contextMock.Setup(m => m.Progresses);
            _participant = new Participant {
                Id = 1, Email = "", Scores = null, UserSetting = null, Progress = null
            };
            _controller = new ProgressController(_contextMock.Object, _participant);
            SetupControllerForTests(_controller);

            Progress progress = new Progress {
                Assignment = list.Find(1), Id = 2, Participant = _participant, StartTime = DateTime.Now
            };
            var result = _controller.Put(1, progress);

            Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
        }