public void GetById(string expected, int id, bool valid) { TagsResponse response = repo.GetById(id); Assert.AreEqual(valid, response.Success); if (valid == true) { Tag actual = response.Tags.First(); Assert.AreEqual(expected, actual.TagName); } }
public TagsResponse GetById(int id) { var context = new PersonalBlogEntities(); if (id == 0) { return(repo.GetById(id)); } if (context.Tags.FirstOrDefault(t => t.TagId == id) == null) { var response = new TagsResponse(); response.Success = false; response.Message = "That tag is not valid."; return(response); } return(repo.GetById(id)); }