public async Task UpdateLookupCode() { var id = await AddCourtRole(); var result = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(await _controller.Find(id)); Detach(); //We get an exception if we don't detach before the update. var createdById = new Guid(); result.CreatedById = createdById; result.CreatedOn = DateTime.Now; result.Description = "test"; result.EffectiveDate = DateTime.Now; result.Code = "gg"; result.SubCode = "gg2"; result.ExpiryDate = DateTime.Now; result.SortOrder = 5; result.Type = LookupTypes.JailRole; var updatedById = new Guid(); result.UpdatedById = updatedById; result.UpdatedOn = DateTime.Now; result.LocationId = 6; var controllerResult = await _controller.Update(result); HttpResponseTest.CheckForValidHttpResponseAndReturnValue(controllerResult); result = HttpResponseTest.CheckForValidHttpResponseAndReturnValue(await _controller.Find(id)); Assert.Equal(createdById, result.CreatedById); Assert.Equal(DateTime.Now, result.CreatedOn, TimeSpan.FromSeconds(10)); Assert.Equal("test", result.Description); Assert.Equal(DateTime.Now, result.EffectiveDate.Value, TimeSpan.FromSeconds(10)); Assert.Equal(DateTime.Now, result.ExpiryDate.Value, TimeSpan.FromSeconds(10)); Assert.Equal(5, result.SortOrder); Assert.Equal(LookupTypes.JailRole, result.Type); Assert.Equal(updatedById, result.UpdatedById); Assert.Equal(DateTime.Now, result.UpdatedOn.Value, TimeSpan.FromSeconds(10)); Assert.Equal("gg", result.Code); Assert.Equal("gg2", result.SubCode); }
public async Task UpdateLookupCode() { await Db.Database.EnsureDeletedAsync(); var newLocation = new Location { Name = "6", Id = 6 }; await Db.Location.AddAsync(newLocation); await Db.SaveChangesAsync(); Detach(); var id = await AddCourtRole(); var result = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(await _controller.Find(id)); Detach(); //We get an exception if we don't detach before the update. result.Description = "test"; result.EffectiveDate = DateTime.Now; result.Code = "gg"; result.SubCode = "gg2"; result.Type = LookupTypes.JailRole; result.LocationId = 6; result.SortOrderForLocation = new LookupSortOrderDto { LocationId = 6, LookupCodeId = 6 }; var controllerResult = await _controller.Update(result); HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult); result = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(await _controller.Find(id)); Assert.Equal("test", result.Description); Assert.Equal(DateTimeOffset.Now.DateTime, result.EffectiveDate.Value.DateTime, TimeSpan.FromSeconds(10)); Assert.Equal(LookupTypes.JailRole, result.Type); Assert.Equal("gg", result.Code); Assert.Equal("gg2", result.SubCode); Assert.Equal(6, result.LocationId); }