// POST api/assessments
        public HttpResponseMessage Post([FromBody] AssessmentModel model)
        {
            var assessment = Mapper.Map <Assessment>(model);

            assessment = manager.Insert(assessment);

            var newModel = TheModelFactory.Create(assessment);
            var response = Request.CreateResponse(HttpStatusCode.Created, newModel);
            var link     = newModel.Links.Where(l => l.Rel == "self").FirstOrDefault();

            if (link != null)
            {
                response.Headers.Location = new Uri(link.Href);
            }

            return(response);
        }
Ejemplo n.º 2
0
        public void Insert_Assessment_Returns_Assessment()
        {
            // Arrange
            var fakeAssessment = new Assessment()
            {
                Id = 1000, Name = "test fake assessment", Duration = 10
            };

            assessmentRepository.Setup(x => x.Insert(It.IsAny <Assessment>()));
            assessmentManager = new AssessmentManager(fakeUoW.Object, assessmentRepository.Object, null);
            //// Act
            var newAssessment = assessmentManager.Insert(fakeAssessment);

            //// Assert
            Assert.IsNotNull(newAssessment, "Result is null");
            Assert.IsInstanceOfType(newAssessment, typeof(Assessment), "Invalid Enitity");
            Assert.AreEqual(1000, newAssessment.Id);
        }