我们在公司开始了新项目。我们最终确定架构如下
有5个不同的项目如下
1)BusinessEntities(类库),其中包含如下DataContract
[DataContract]
public class Cities
{
/// <summary>
/// Gets or sets City Id
/// </summary>
[DataMember]
public int Id { get; set; }
/// <summary>
/// Gets or sets City name
/// </summary>
[DataMember]
[Display(Name = "CityName", ResourceType = typeof(DisplayMessage))]
[Required(ErrorMessageResourceName = "CityName", ErrorMessageResourceType = typeof(ErrorMessage))]
[RegularExpression(@"[a-zA-Z ]*", ErrorMessageResourceName = "CityNameAlphabates", ErrorMessageResourceType = typeof(ErrorMessage))]
[StringLength(50, ErrorMessageResourceName = "CityNameLength", ErrorMessageResourceType = typeof(ErrorMessage))]
public string Name { get; set; }
}
2) 接口包含
[ServiceContract]
public interface ICity : IService<CityViewModel>
{
[OperationContract]
Status Add(Cities entity);
}
3) 包含 WCF 服务实现的 DAL
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class City : ICity
{
public Status Add(Cities entity)
{
//Insert Logic goes here
}
}
4)调用WCF服务的Webcomponent
public class City
{
public static Status Add(Cities entity)
{
using (var service = new WcfServiceProvider<ICity>())
{
return service.GetProxy().Add(entity);
}
}
}
5)调用webcomponent访问服务的UI(Asp.Net MVC项目)
City.Add(entity);
现在我们最终确定这个结构。但问题是如何使用存储库模式进行单元测试?如果可以,是否可以在此结构上使用存储库模式?还是我们必须使用其他任何模式?