当前位置: 首页>>代码示例>>C#>>正文


C# ProductRepository.GetProductById方法代码示例

本文整理汇总了C#中ProductRepository.GetProductById方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.GetProductById方法的具体用法?C# ProductRepository.GetProductById怎么用?C# ProductRepository.GetProductById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductRepository的用法示例。


在下文中一共展示了ProductRepository.GetProductById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProductById_ProductDoesNotExist_ShouldReturnNull

        public void GetProductById_ProductDoesNotExist_ShouldReturnNull()
        {
            using (var repository = new ProductRepository())
            {
                var actual = repository.GetProductById(1001);

                Assert.IsNull(actual);
            }
        }
开发者ID:mnjstwins,项目名称:NHibernate.CacheDb,代码行数:9,代码来源:ProductRepositoryTest.cs

示例2: GetProductById_GetTestProduct_ShouldReturnExpectedValue

        public void GetProductById_GetTestProduct_ShouldReturnExpectedValue()
        {
            using (var repository = new ProductRepository())
            {
                var actual = repository.GetProductById(2);

                Assert.IsNotNull(actual);
                Assert.AreEqual("Test Product 2", actual.Name);
                Assert.AreEqual("Test Category", actual.Category);
            }
        }
开发者ID:mnjstwins,项目名称:NHibernate.CacheDb,代码行数:11,代码来源:ProductRepositoryTest.cs

示例3: HowToConfigurePipelineBehaviour

    public void HowToConfigurePipelineBehaviour()
    {
      using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db())
      {
        // create a product to get from the repository
        object expectedProduct = new object();
        string productId = "1";

        // configure Pipeline Watcher to expect a pipeline call where the args Custom Data
        // contains ProductId equals "1". Once the args received the pipeline result is set
        // to the Product Custom Data property
        db.PipelineWatcher
          .WhenCall("findProductById")
          .WithArgs(a => a.CustomData["ProductId"].Equals(productId))
          .Then(a => a.CustomData["Product"] = expectedProduct);

        // create a repository and call get product method
        ProductRepository repository = new ProductRepository();
        var actualProduct = repository.GetProductById(productId);

        // assert the received product is the same as the expected one
        Xunit.Assert.Equal(expectedProduct, actualProduct);
      }
    }
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:24,代码来源:GettingStarted.cs

示例4: HowDoIConfigureThePipelineBehaviour

    public void HowDoIConfigureThePipelineBehaviour()
    {
      using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db())
      {
        // create a product to get from the repository
        object expectedProduct = new object();

        // configure processing of the pipeline arguments. Will set the 'expectedProduct' instance 
        // to CustomData["Product"] property only when the CustomData["ProductId"] is "1"
        string productId = "1";

        // configure a pipeline watcher to expect a pipeline call where the args custom data contains
        // ProductId. Once the args received the pipeline result is set into Product custom data property
        db.PipelineWatcher
          .WhenCall("findProductById")
          .WithArgs(a => a.CustomData["ProductId"].Equals(productId))
          .Then(a => a.CustomData["Product"] = expectedProduct);

        // create a repository and call get product method
        ProductRepository repository = new ProductRepository();
        var actualProduct = repository.GetProductById(productId);

        // assert the received product is the same as the expected one
        Assert.Equal(expectedProduct, actualProduct);
      }
    }
开发者ID:udalovas,项目名称:Sitecore.FakeDb,代码行数:26,代码来源:GettingStarted.cs


注:本文中的ProductRepository.GetProductById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。