param>
void Add(CategoryInfo category);
/// <summary>
/// 修改分类名称
/// </summary>
/// <param name="id"></param>
/// <param name="name"></param>
void ChangeName(int id,string name);
/// <summary>
/// 删除分类
/// </summary>
/// <param name="id"></param>
void Remove(int id);
/// <summary>
/// 取得某个分类详细信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
CategoryInfo GetDetail(int id);
/// <summary>
/// 取得所有分类
/// </summary>
/// <returns></returns>
List<CategoryInfo> GetAll();
}
}
IAnnounceService.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MVCDemo.Models.Entities;
namespace MVCDemo.Models.Interfaces
{
/// <summary>
/// 公告服务组件接口
/// </summary>
public interface IAnnounceService
{
/// <summary>
/// 发布公告
/// </summary>
/// <param name="announce"></param>
void Release(AnnounceInfo announce);
/// <summary>
/// 修改公告信息
/// </summary>
/// <param name="announce"></param>
void Notify(AnnounceInfo announce);
/// <summary>
/// 删除公告
/// </summary>
/// <param name="id"></param>
void Remove(int id);
/// <summary>
/// 取得公告 详细内容
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
AnnounceInfo GetDetail(int id);
/// <summary>
/// 取得 某个分类下的所有公告
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
List<AnnounceInfo> GetByCategory(CategoryInfo category);
}
}
然后,我们在MockModels下建立两个Mock业务 逻辑服务模型。注意它们要各自实现自己的接口。
MockCategoryService.cs:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MVCDemo.Models.Interfaces;
using MVCDemo.Models.Entities;
namespace MVCDemo.Models.MockModels
{
/// <summary>
/// “欺骗”服务组件, 用于模拟分类的业务服务
/// </summary>
public class MockCategoryService : ICategoryService
{
/// <summary>
/// 添加分类
/// </summary>
/// <param name="category"></param>
public void Add(CategoryInfo category)
{
return;
}
/// <summary>
/// 修改分类名称
/// </summary>
/// <param name="id"></param>
/// <param name="name"></param>
public void ChangeName(int id, string name)
{
return;
}
/// <summary>
/// 删除分类
/// </summary>
/// <param name="id"></param>
public void Remove(int id)
{
return;
}
/// <summary>
/// 取得某个分类详细信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public CategoryInfo GetDetail(int id)
{
return new Ca
|