public void GetAllDecksByCategoryTest() { var sut = new CatalogBll(this.catalog.Object, this.converter.Object); foreach (var category in categories) { var actual = sut.GetAllDecksByCategory(category.Name); this.catalog.Verify( cat => cat.GetAllDecksByCategory(category.Name), Times.AtLeastOnce()); Assert.That(actual, Is.All.InstanceOf(typeof(DeckDTO))); } }
public IHttpActionResult GetDecksByCategory(string categoryName) { try { IEnumerable <DeckDTO> decks = catalog .GetAllDecksByCategory(categoryName); if (decks == null) { throw new Exception("Decks aren't found by this category!"); } return(Ok(decks.ToList())); } catch (ArgumentNullException ex) { var message = $"Category with name = {categoryName} " + $"not found. {ex.Message}"; return(BadRequest(message)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }