Ejemplo n.º 1
0
        public async void UpdateOneExperience_NotFound()
        {
            // arrange
            mockRepo.Setup(x => x.GetFirstByExpressionAsync(It.IsAny <Expression <Func <Experience, bool> > >())).ReturnsAsync(() => null);
            var id     = Guid.NewGuid();
            var newObj = new EditExperienceDto()
            {
                Address = "hejhej"
            };

            // act
            var result = await controller.UpdateOneExperience(id, newObj);

            // assert
            var resultValue = Assert.IsAssignableFrom <NotFoundObjectResult>(result);
            var returnedObj = Assert.IsType <ErrorObject>(resultValue.Value);

            Assert.Equal("Could not find experience to edit", returnedObj.Error);
            Assert.Equal("PUT", returnedObj.Method);
            Assert.Equal($"/api/experiences/{id}", returnedObj.At);
            Assert.Equal(404, returnedObj.StatusCode);
        }