public async Task TestPutUserAsync() { // Arrange var mockSet = new Mock <DbSet <User> >(); var mockContext = new Mock <userContext>(); var mockUserDbSet = GetQueryableMockUserDbSet(); mockContext.Setup(m => m.User).Returns(mockUserDbSet.Object); var service = new userController(mockContext.Object); var model = new User { Id = 1, Username = "******", Password = "******" }; //Act // Breaks on 'EntityState.Modified', unsure as to why, function works when state is ignored. var response = await service.Putuser(model.Id, model) as HttpStatusCodeResult; //Unsure why this does not work. //Verify Assert.IsNotNull(response); Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode); }