---
title: "試験"
slug: "testing"
abstract: ""
---
# 試験

Fluent SDKは、開発者がCHインスタンスを更新し、テスト結果を確認するためのより良い方法を提供します。

## Web Client SDKを通じたFluent SDKテストライブラリの使用

-   [Web Client SDKの「開始」手順](https://doc.sitecore.com/ch/ja/developers/cloud-dev/get-started-1523379.html "Get started")に従ってNuGetフィードの設定を行います
-   プロジェクトに **Stylelabs.M.Sdk.Fluent.Testing** パッケージへの参照を追加してください

以下の例は、新しい**M.Tag**エンティティを作成し、保存後にエンティティのプロパティを主張します

var endpoint = new Uri("https://your.m.endpoint.com");
var oath = new OAuthPasswordGrant
{
 ClientId = "client\_id",
 ClientSecret = "client\_secret",
 UserName = "username",
 Password = "password"
};

var fluentClient = new FluentClient(MClientFactory.CreateMClient(endpoint, oauth));

var culture = new CultureInfo("en-US");
var name = "A.Tag";
var label = "Tag Label";
var synonyms = "Tag 1, Tag 2, Tag 3";

var newTag =
 fluentClient.EntityFactory.Create("M.Tag")
 .SetPropertyValue("TagName", name)
 .SetPropertyValue("TagLabel", culture, label)
 .SetPropertyValue("Synonyms", culture, synonyms)
 .Save();

fluentClient.Entities.Get(newTag.Id.Value)
 .AssertPropertyEqual("TagName", name)
 .AssertPropertyEqual("TagLabel", culture, label)
 .AssertPropertyEqual("Synonyms", culture, synonyms);

以下の例では、子関係を持つ新しい**M.Tag**エンティティを作成し、保存後にそのエンティティの関係を主張します

var endpoint = new Uri("https://your.m.endpoint.com");
var oath = new OAuthPasswordGrant
{
 ClientId = "client\_id",
 ClientSecret = "client\_secret",
 UserName = "username",
 Password = "password"
};

var fluentClient = new FluentClient(MClientFactory.CreateMClient(endpoint, oauth));

var culture = new CultureInfo("en-US");

var parentTag =
 fluentClient.EntityFactory.Create("M.Tag")
 .SetPropertyValue("TagName", "IntegrationTest.TestParentTag1")
 .SetPropertyValue("TagLabel", culture, "Test Parent Label")
 .Save();

var childTag =
 fluentClient.EntityFactory.Create("M.Tag")
 .SetPropertyValue("TagName", "IntegrationTest.TestChildTag1")
 .SetPropertyValue("TagLabel", culture, "Test Child Label")
 .Save();

parentTag
 .Children(
 "TagToSelf",
 relation = relation.Children.Add(childTag.Id.Value))
 .Save();

parentTag.AssertRelation("TagToSelf", RelationRole.Parent, childTag);

より詳細な [ウォークスルー](https://doc.sitecore.com/ch/ja/developers/cloud-dev/walkthrough--using-stylelabs-m-sdk-fluent-through-the-web-client-sdk.html "Walkthrough: using Stylelabs.M.SDK.Fluent through the Web Client SDK")