예제 #1
0
    public void Variant_Published_Culture_Names_Track_Dirty_Changes()
    {
        var contentType = new ContentTypeBuilder()
                          .WithAlias("contentType")
                          .WithContentVariation(ContentVariation.Culture)
                          .Build();
        var content = new ContentBuilder()
                      .WithId(1)
                      .WithVersionId(1)
                      .WithName("content")
                      .WithContentType(contentType)
                      .Build();

        const string langFr = "fr-FR";

        content.ChangeContentType(contentType);

        Assert.IsFalse(content.IsPropertyDirty("PublishCultureInfos")); // hasn't been changed

        Thread.Sleep(500);                                              // The "Date" wont be dirty if the test runs too fast since it will be the same date
        content.SetCultureName("name-fr", langFr);
        content.PublishCulture(CultureImpact.Explicit(langFr, false));  // we've set the name, now we're publishing it
        Assert.IsTrue(
            content.IsPropertyDirty("PublishCultureInfos"));            // now it will be changed since the collection has changed
        var frCultureName = content.PublishCultureInfos[langFr];

        Assert.IsTrue(frCultureName.IsPropertyDirty("Date"));

        content.ResetDirtyProperties();

        Assert.IsFalse(content.IsPropertyDirty("PublishCultureInfos")); // it's been reset
        Assert.IsTrue(content.WasPropertyDirty("PublishCultureInfos"));

        Thread.Sleep(500);                                             // The "Date" wont be dirty if the test runs too fast since it will be the same date
        content.SetCultureName("name-fr", langFr);
        content.PublishCulture(CultureImpact.Explicit(langFr, false)); // we've set the name, now we're publishing it
        Assert.IsTrue(frCultureName.IsPropertyDirty("Date"));
        Assert.IsTrue(content.IsPropertyDirty("PublishCultureInfos")); // it's true now since we've updated a name
    }