Nunit Mocking有点令人困惑

时间:2015-09-29 22:56:17

标签: c# mocking nunit

如何模拟查询,我想在Nunit中测试它。有人可以帮我解决片段吗?这是确切的Service.cs,我需要模拟并在同一个Nunit上做。

internal class Sample : ISsample
{
  public sample( IRepository<ProductVariant> productVariantRepository, IRepository<Product> productRepository)
    {

        _productVariantRepository = productVariantRepository;
        _productRepository = productRepository;
    }
   public string getValueabc(int a, int b)
   {
            vvar productVariantId =
                (from pv in _productVariantRepository.Table
                 join p in _productRepository.Table on pv.ProductId equals p.Id
                 where !p.Deleted && !pv.Deleted && p.Id == sku
                 orderby pv.Published descending
                 select pv.Id).FirstOrDefault();

            if (productVariantId == 0)
            {
                throw new ErrorCodeException(CatalogErrorCode.ProductVariantNotFound);
            }
           return "Hi";
     }
 }

0 个答案:

没有答案