मैं इन कक्षाओं में है:एक स्थैतिक वर्ग (यूनिटऑफवर्क केस) के साथ स्थिर वर्ग कैसे करें?
public static class UnitOfWorkSS
{
public static IUnitOfWork Begin()
{
return IoC.Resolve<IUnitOfWork>();
}
}
public class PostService
{
using (IUnitOfWork unitOfWork = UnitOfWorkSS.Begin())
{
//don't forget to sanitize html content
htmlContent = _htmlSanitizer.Sanitize(htmlContent);
IPost post = _factory.CreatePost(byUser, title, htmlContent);
_postRepository.Add(post);
unitOfWork.Commit();
}
}
मैं वर्गों UnitOfWorkSS
और unitOfWork
कैसे नकली कर सकते हैं?
विकल्प 2 मेरे लिए बेहतर लगता है कि विकल्प 1 राज्य को केवल टेस्टेबल बनाने के लिए एक स्थैतिक वर्ग में पेश करता है - हालांकि शायद यह ओपी सभी की तलाश में है। – aaaaaa