public void GetOwnersTest() { // Try finding all products IEnumerable <Owner> testOwners = _repository.GetOwners(); Assert.IsNotNull(testOwners); // Test if null }
/// <summary> /// Return CatList View /// </summary> /// <returns></returns> public ActionResult CatList() { IEnumerable <Cat> _cats; try { // filter pet owners currently owns some pets var _owners = _iPetOwnerRepository.GetOwners().Where(i => i.Pets != null); // create new list with required fields on the page _cats = from owner in _owners from pet in owner.Pets where pet.Type.ToLower() == "cat" select new Cat { Name = pet.Name, OwnerGender = owner.Gender }; } catch (Exception ex) { // Log exception in to application insights Dictionary <string, string> _properties = new Dictionary <string, string> { { Logging.Location, "CatListController - CatList" }, { Logging.Message, ex.Message }, { Logging.StackTrace, ex.StackTrace } }; _telemetry.TrackException(ex, _properties); _cats = null; } // return View return((_cats != null) ? View(viewName: ViewNamne.CatList, model: _cats) : View(ViewNamne.Error)); }