Testing
Current version: 3.3
The Fluent SDK provides a better way for developers to update a CH instance and then checks the results of their test.
Using Fluent SDK testing library through the Web Client SDK
- Follow the "Getting Started" instructions for the Web Client SDK to configure the NuGet feed
- Add a reference to the
Stylelabs.M.Sdk.Fluent.Testing
package to your project
The following example creates a new M.Tag
entity and asserts the entity's properties once it's saved
RequestResponse
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);
The following example creates a new M.Tag
entity with a child relation and asserts the entity's relations once it's saved
RequestResponse
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);
A more detailed Walkthrough