public CategoryModel ToExternalModel(Category category, bool includeAllNotes) { Contract.Requires<ArgumentNullException>(category != null, "category"); Contract.Ensures(Contract.Result<CategoryModel>() != null); Contract.Ensures(Contract.Result<CategoryModel>().Id == category.Id); throw new NotImplementedException(); }
public void WhenSomeCategoriesThenThoseCategoriesShouldBeReturned() { //! given: unit of work with 3 categories. var cat1 = new Category("Foo"); var cat2 = new Category("Bar"); var cat3 = new Category("Spinazie"); IDbSet<Category> categories = new DbSetMockBuilder<Category>() .ContainingEntity(cat1) .ContainingEntity(cat2) .ContainingEntity(cat3) .Build(); IUnitOfWork unitOfWork = new UnitOfWorkMockBuilder() .WithCategoryRepository( categories ) .Build(); //! when: controller is asked for the list. CategoryController subject = new CategoryControllerBuilder() .WithUnitOfWork(unitOfWork) .Build(); var viewResult = (ViewResult)subject.List(); var model = (IEnumerable<CategoryModel>)viewResult.ViewData.Model; //! then: a model with empty categories should be returned. model.Should().NotBeNull(); model.Count().Should().Be(3); model.Should().OnlyContain(c => new[] { cat1, cat2, cat3 }.Any(cat => cat.Id == c.Id)); }
public CategoryModel ToExternalModel(Category category, int noteCount) { Contract.Requires<ArgumentNullException>(category != null, "category"); Contract.Ensures(Contract.Result<CategoryModel>() != null); Contract.Ensures(Contract.Result<CategoryModel>().Id == category.Id); Contract.Ensures(Contract.Result<CategoryModel>().NoteCount == noteCount); throw new NotImplementedException(); }
public void UpdateEntity(Category category, CategoryModel categoryModel) { Contract.Requires<ArgumentNullException>(category != null); Contract.Requires<ArgumentNullException>(categoryModel != null); Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(categoryModel.Name), "Category requires a name."); Contract.Requires<ArgumentException>(category.Id == categoryModel.Id, "Id's of category and category model should match."); throw new NotImplementedException(); }
private CategoryModel ToExternalModel(Category category, int? noteCount, bool includeAllNotes) { var categoryModel = new CategoryModel() { Id = category.Id, Name = category.Name, NoteCount = noteCount ?? category.Notes.Count() }; if (includeAllNotes) { categoryModel.Notes = category.Notes .Select(_noteConverter.ToClientNoteModel) .ToList(); } return categoryModel; }
/// <summary> /// Update the intenral entity with the data from the external model /// </summary> /// <param name="category">The entity to update.</param> /// <param name="categoryModel">The model to use to update the entity.</param> public void UpdateEntity(Category category, CategoryModel categoryModel) { throw new NotSupportedException("Renaming the category is currently not supported"); }
/// <summary> /// Convert the internal <see cref="Category"/> entity to an external <see cref="CategoryModel"/> using a predefined number of notes. /// </summary> /// <param name="category">The internal category to convert to an external CategoryModel</param> /// <param name="noteCount">Set to the number of notes in the category.</param> /// <returns>The entity converted to an external model.</returns> public CategoryModel ToExternalModel(Category category, int noteCount) { return ToExternalModel(category, noteCount, false); }
/// <summary> /// Convert the internal <see cref="Category"/> entity to an external <see cref="CategoryModel"/>. /// </summary> /// <param name="category">The internal category to convert to an external CategoryModel</param> /// <param name="includeAllNotes">Set to <c>true</c> to include all the notes.</param> /// <returns>The entity converted to an external model.</returns> public CategoryModel ToExternalModel(Category category, bool includeAllNotes) { return ToExternalModel(category, noteCount: null, includeAllNotes: includeAllNotes); }
/// <summary> /// Convert the internal entity /// </summary> /// <param name="category">The internal entity to conver to an external entity</param> /// <returns>The entity converted to an external model.</returns> public CategoryModel ToExternalModel(Category category) { return ToExternalModel(category, noteCount: 0, includeAllNotes: false); }
public NoteBuilder InCategory(Category category) { _category = category; return this; }