Git Product home page Git Product logo

sitecore.fakedb's Introduction

Sitecore FakeDb

# Build Status tests

This is the unit testing framework for Sitecore that enables creation and manipulation of Sitecore content in memory. It is designed to minimize efforts for the test content initialization keeping focus on the minimal test data rather than comprehensive content tree representation.

Here is a typical FakeDb unit test:

[Fact]
public void HowToCreateSimpleItem()
{
  using (var db = new Db
    {
      new DbItem("Home") { { "Title", "Welcome!" } }
    })
  {
    Sitecore.Data.Items.Item home = db.GetItem("/sitecore/content/home");
    Xunit.Assert.Equal("Welcome!", home["Title"]);
  }
}

Install with NuGet

You can install the framework via NuGet:

PM> Install-Package Sitecore.FakeDb

For information about configuring assembly references and applying the license file, see the Installation page.

Create items in memory

Explore the following list of articles to start creating items for your unit tests:

Or create your content using deserialized data.

Mock all the rest

With FakeDb you can configure behavior of the static managers substituting the corresponding providers with mocks. The following security providers can be mocked:

You can also configure behavior of other areas such as:

For more information about the FakeDb features follow the wiki pages.

sitecore.fakedb's People

Contributors

andybutland avatar dharnitski avatar hermanussen avatar jackthehack avatar michaelthyregod avatar mike-glass avatar mikeedwards83 avatar pveller avatar sshushliapin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sitecore.fakedb's Issues

Cannot read items from 'outer' db if 'inner' db is disposed

I would not recommend to use nested Db instances. Nevertheless, the code below should not fail:

// arrange
using (var db = new Db { new DbItem("home") })
{
  // act
  using (new Db())
  {
  }

  // assert
  db.GetItem("/sitecore/content/home").Should().NotBeNull(); // fails
}

Move database commands configuration out of the `App.conifg` file

Starting from 7.5 the Database class constructor became internal. In result all the fakedb commands have been registered explicitly in the configuration file:

<Engines.DataEngine.Commands.AddFromtemplatePrototype type="Sitecore.FakeDb.Data.Engines.DataCommands.AddFromTemplateCommand, Sitecore.FakeDb" />
<Engines.DataEngine.Commands.AddVersionPrototype type="Sitecore.FakeDb.Data.Engines.DataCommands.AddVersionCommand, Sitecore.FakeDb" />
<Engines.DataEngine.Commands.BlobStreamExistsPrototype type="Sitecore.FakeDb.Data.Engines.DataCommands.BlobStreamExistsCommand, Sitecore.FakeDb" />
...

Totally it's 3x19=57 rows of wasted space in the config file.

The registrations should gone.

Item with children and fields will result in empty field list

When using the initializer to create a DbItem with both children AND fields (the combination is important here) the list of fields in the object will be empty. I'm using the following example code:

using (var db = new Db
            {
                new DbTemplate("Media folder", directoryTemplateId),
                new DbItem("DownloadDir")
                {
                    TemplateID = directoryTemplateId,
                    Children =
                    {
                        new DbItem("SubdirOne")
                        {
                            TemplateID = directoryTemplateId,
                        }
                    },
                    Fields =
                    {
                        new DbField("test1"),
                        new DbField("test2")
                    }
                }
            })

When checking the contents of the Item that has been given the name "DownloadDir" I would expect this item to have one child and the following two fields: 'test1' and 'test2'. However, the list of Fields is always empty, which seems to be incorrect.

Exception when trying to retrieve BaseTemplates

I haven't dug into the code to troubleshoot this very much, but I thought I would get it out there in case there's an obvious fix you can see.

It seems that I cannot retrieve BaseTemplates:

using (var db = new Db() {new DbItem("page")})
{
  var page = db.GetItem("/sitecore/content/page");
  var baseTemplates = page.Template.BaseTemplates;
  Assert.NotNull(baseTemplates);
}

Get this exception every time. I have tried specifying a fake template, using a common template that FakeDb builds automatically (like Folder).

System.ArgumentNullException : Value cannot be null.
Parameter name: itemId
   at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.FakeDb.Data.Engines.DataStorage.GetSitecoreItem(ID itemId, Language language, Version version) 
   at Sitecore.FakeDb.Data.Engines.DataStorage.GetSitecoreItem(ID itemId, Language language)
   at Sitecore.FakeDb.Data.Engines.DataCommands.GetParentCommand.DoExecute() 
   at Sitecore.Data.Engines.EngineCommand`2.Execute()
   at Sitecore.Data.Managers.ItemProvider.GetParent(Item item)
   at Sitecore.Data.Managers.ItemProvider.GetParent(Item item, SecurityCheck securityCheck)
   at Sitecore.Security.AccessControl.ItemAuthorizationHelper.GetAncestorAccess(Item item, Account account, AccessRight accessRight, PropagationType propagationType)
   at Sitecore.Security.AccessControl.ItemAuthorizationHelper.GetItemAccess(Item item, Account account, AccessRight accessRight, PropagationType propagationType)
   at Sitecore.Security.AccessControl.ItemAuthorizationHelper.GetAccess(Item item, Account account, AccessRight accessRight)
   at Sitecore.FakeDb.Security.AccessControl.FakeAuthorizationProvider.GetAccessCore(ISecurable entity, Account account, AccessRight accessRight)
   at Sitecore.Security.AccessControl.AuthorizationProvider.GetAccess(ISecurable entity, Account account, AccessRight accessRight)
   at Sitecore.FakeDb.Security.AccessControl.FakeAuthorizationProvider.GetAccess(ISecurable entity, Account account, AccessRight accessRight)
   at Sitecore.Security.AccessControl.AuthorizationManager.IsAllowed(ISecurable entity, AccessRight right, Account account)
   at Sitecore.Data.Managers.ItemProvider.ApplySecurity(Item item, SecurityCheck securityCheck)
   at Sitecore.Data.Managers.ItemManager.GetItem(ID itemId, Language language, Version version, Database database)
   at Sitecore.Data.TemplateRecords.GetTemplate(ID templateID, Language language)
   at Sitecore.Data.Items.TemplateItem.get_BaseTemplates()

Versioned field value is not empty for item in `Invariant` language

Should pass:

    [Fact]
    public void ShouldGetEmptyFieldValueForInvariantLanguage()
    {
      // arrange
      using (var db = new Db
                        {
                          new DbItem("home") { { "Title", "Hello!" } }
                        })
      {
        // act
        var item = db.Database.GetItem("/sitecore/content/home", Language.Invariant);

        // assert
        item["Title"].Should().BeEmpty();
      }
    }

Unable to edit an **empty** item field inherited from a base template

The following code fails with "Item field not found" error:

using (var db = new Db
                  {
                    new DbTemplate("base", baseTemplate) { new DbField(fieldId) },
                    new DbTemplate("sample", templateId) { BaseIDs = new[] { baseTemplate } },
                    new DbItem("Home", ID.NewID, templateId)
                  })
{
  var item = db.GetItem("/sitecore/content/Home");

  // act
  using (new EditContext(item))
  {
    item.Fields[fieldId].Value = "new value";
  } // System.InvalidOperationException : Item field not found. Item: 'Home'
}

Does not fail if the Home item receives some field value during initialization.

LinkManager

I was having problems getting an items Path in my tests, e.g:

Assert.AreEqual(TargetPath+"/Child2", child.Path);

The issue was caused by the linkManager not being set. I added the following to the App.Config:

  <linkManager defaultProvider="sitecore">
      <providers>
          <clear />
          <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" lowercaseUrls="false" shortenUrls="true" useDisplayName="false" />
      </providers>
  </linkManager>

And this solved my problem. Was the link manager removed for a reason?

Cannot get a child item by path if the item is added using the Children collection

When adds an item using yhr item.Children property, the child's FullPath property should be updated so that the child item can be requested by path. The following test should pass:

[Fact]
public void ShouldGetItemChildByPathIfAddedUsingChildrenCollection()
{
  // arrange
  using (var db = new Db
                {
                  new DbItem("home")
                    {
                      Children = { new DbItem("sub-item") }
                    }
                })
  {
    // act
    var item = db.GetItem("/sitecore/content/home/sub-item");

    // assert
    item.Should().NotBeNull();
  }
}

Deserialization of base templates broken in latest version

In version 0.25.1, the following file gives an error when deserializing template items with multiple base templates. Obviously because it attempts to parse a single ID, where it can actually be a list. The file:
https://github.com/sergeyshushlyapin/Sitecore.FakeDb/blob/2c7afe3dfb032b4740d765696c9659d99a385d52/src/Sitecore.FakeDb.Serialization/Pipelines/CopySharedFields.cs

Perhaps due to a refactoring? I reverted to 0.25.0 and it works correctly there.

(actually, some other stuff appears to be broken after 0.24.0; I'll look into it personally when I have the time)

AutoFixture integration

Should be possible to deserialize items using AutoData attribute:

public class AutoFixtureTest
{
  [Theory, AutoDb]
  public void ShouldDeserializeItems(Db db)
  {
    // act
    var item = db.GetItem("/sitecore/content/home");

    // assert
    item.Should().NotBeNull();
    item["Title"].Should().Be("Sitecore");
  }
}

public class AutoDbAttribute : AutoDataAttribute
{
  public AutoDbAttribute()
    : base(new Fixture().Customize(new AutoDbCustomization()))
  {
  }
}

public class AutoDbCustomization : ICustomization
{
  public void Customize(IFixture fixture)
  {
    fixture.Customize<Db>(d => d.Do(x => x.Add(new DsDbItem("/sitecore/content/home"))));
  }
}

Deserialize item fails if there is an item with the same id

It is not possible to add an item if there is another item with the same id exists. That is the expected behavior for regular items created manually, but it should not be the case for deserialized items. The deserialized items should override the existing ones if any:

image

How locate fake items under /sitecore/system ?

Hello

How in right way I can add fake items under /sitecore/system ?

For example, for /sitecore/content I use next code:

[TestFixtureSetUp]
public void SetUpTest()
{
this.db = new Db
{
new DbItem("Home") { { "Title", "Welcome!" } }
};
}

I see that I can get /sitecore/system item with using:
this.db.GetItem("/sitecore/system");

But it will be a real Sitecore item, not fake item.


Thanks.

Unable to get an item if there is a missing base template

Should pass:

// arrange
var templateId = ID.NewID;
var missingBaseTemplateId = ID.NewID;

using (var db = new Db
                  {
                    new DbTemplate(templateId) { BaseIDs = new[] { missingBaseTemplateId } },
                    new DbItem("home", ID.NewID, templateId)
                  })
{
  // act & assert
  db.GetItem("/sitecore/content/home").Should().NotBeNull();
}

Introduce strongly typed LinkField configuration

In order to cofigure a link field in unit test one can use raw xml:

using (var db = new Db
{
  new DbItem("home")
    {
      { "link", "<link linktype=\"external\" url=\"http://google.com\" />" }
    }
})

Would be nice to be able to configure the same field using a special field type with appropriate properties:

using (var db = new Db
{
  new DbItem("home")
    {
      new DbLinkField("link") { LinkType = "external", Url = "http://google.com" }
    }
})

Item Versions

How do I tell fake db explicitly not to create a version in a specific language?

For example the following test:

        using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db
        {            
            new Sitecore.FakeDb.DbItem(itemName2, itemId2)
            {
                new DbField(FieldName)
                {
                    {"en",1,"faea"}
                }
            }
        })
        {

            var language = LanguageManager.GetLanguage("af-ZA");
            var target = database.GetItem("/sitecore/content/{0}".Formatted(itemName2), language);

            Assert.AreEqual(0, target.Versions.Count);
       }

Will fail because FakeDb always returns an entry n the Versions list for the requested language. This is different from Sitecore's default behaviour which is to return an empty Versions list.

Specify item branch id

It's not possible to create an item from a branch in FakeDb but in some cases it might be helpful to specify the item.BranchId in the // arrange section.

Cannot set and get the `__Final Renderings` field value

The field __Final Renderings is not registered in the Standard template. The test below fails:

[Theory]
[InlineAutoData("__Final Renderings")]
public void ShouldReadStandardFieldValues(string fieldName, string fieldValue, Db db)
{
  // arrange
  db.Add(new DbItem("home") { { fieldName, fieldValue } });

  // act & assert
  db.GetItem("/sitecore/content/home")[fieldName].Should().Be(fieldValue);
}

Create a protected item

  • should be possible to protect/unprotect an item using the Sitecore API
  • should be possible to configure item protection using the FakeDb API when initializing a Db context

Fix Template.OwnFields

Now all the standard fields are treated as 'own' template fields. The following test returns 12 own fields instead of the expected one:

[Fact]
public void ShouldGetOwnFields()
{
  // arrange
  var templateId = ID.NewID;

  using (var db = new Db
                    {
                      new DbTemplate(templateId) { "expected own field" },
                      new DbItem("home", ID.NewID, templateId)
                    })
  {
    var item = db.GetItem("/sitecore/content/home");

    // assert
    item.Template.OwnFields.Count()
      .Should().Be(1, string.Join("\n\r", item.Template.OwnFields.Select(f => f.Name)));
    item.Template.OwnFields.Single().Name.Should().Be("expected own field");
  }
}

Installing Package / Deserialize Items

Just wondering whether there will be an extension to handle serialized items, or allow installation of Packages in this awesome provider.
Even though I am aware that hand creating items and / or templates will work just fine, sometimes data preparation can take a lot of work and time for a developer to prepare inside

  using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db
    {
      // create multiple templates with lots of fields, then create associate items (can be a fair bit) in a hierarchical fashion

    })

The ideal scenario would be a content editor using Sitecore to create a whole bunch of content (with different versions / languages, publishable options etc), and finally creates a Package containing the associated templates and items.

Then in the test case, we can just do something like

  using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db
    {
         InstallPackage("blah.zip")          
    })

Configure ContentSearchManager in unit tests

Recently Kevin Brechbühl (@aquasonic) published a good post: Create simple Unit Tests for the Sitecore Content Search.
I was wondering if it is possible to rewrite the unit test without creating the TestableSearchRepository class. It appeared that the current FakeDb version does not allow this (even through I wrote some unit tests using the Content Search API before).

After I registered the searchManager in the App.config file and created FakeSearchProvider I managed to write the following draft test:

[Fact]
public void ShouldGetProducts()
{
  // arrange
  var searchIndex = Substitute.For<ISearchIndex>();
  searchIndex
    .CreateSearchContext()
    .GetQueryable<ProductSearchResultItem>()
    .Returns(new[]
                {
                  new ProductSearchResultItem { Free = true }, 
                  new ProductSearchResultItem { Free = false },
                  new ProductSearchResultItem { Free = true }
                }.AsQueryable());

  ContentSearchManager.SearchConfiguration.Indexes["fake_index"] = searchIndex;

  var repository = new SearchRepository();

  // act
  var products = repository.GetProducts(null);

  // assert
  Assert.Equal(2, products.Count());
}

Could not find the blob information within the sitecore package generated from fake media item.

Hi, we are going to use fakeDb for our purposes to generate Sitecore packages without the CMS instance.

The normal items going well, but the issue occurs when try to include some fake media items (need to includes some .png icons in Sitecore package) - generated package contains some information about media item but without blob data!

fake_sitecore_package

The code to represent the behavior and generate Sitecore package using fakeDb and necessary sections of .config file for it were attached (sent to your Sitecore email).

Could you take a look why it might be happen? (supposed, some information regarding the blob data should be also mocked during the process)

Separate ShouldSupportAutoIncludeFiles test run fails

Tried to run ShouldSupportAutoIncludeFiles separatly and it fails.
If I'll add using new Db(){} in the beginning of the test then it works.

using (var db = new Db()){            }
using (var db = new Db())
{
                var value2 = Sitecore.Configuration.Settings.GetSetting("UnitTestKey");
                Assert.AreEqual(value2, "UnitTestValue");
}

DbItem constructor with children params

It would be really handy if DbItem has XElement like constructor:

var item = new DbItem("/sitecore/content/Home", 
  new DbItem("child1", 
    new DbItem("grandchild1")));

BlobStreams

Will you be implementing blob support?
E.g:

        using (var db = new Db
        {
            new DbItem(itemName)
            {
                new DbField(FieldName)                    
            }
        })
        {
            var database = Sitecore.Configuration.Factory.GetDatabase("master");
            var item = database.GetItem("/sitecore/content/{0}".Formatted(itemName));


            var field = item.Fields[FieldName];
            field.SetBlobStream(new MemoryStream());


       }

Add all the Sitecore Standard fields to the FakeDb Standard Template

In the issue #64, the missing __Final Renderings field has been added to the Standard Template. All the other existing Sitecore standard fields needs to be registered as well.

It might be challenging to keep the fields set actual for numerous Sitecore versions. Consider implementing some kind of convention like "read all fields from the FieldIds class".

Using provided NUnit runner in JetBrains TeamCity

I am seeing a lot of warning / errors when using JetBrains TeamCity NUnit runner when using Sitecore.FakeDb. The most simplest test as provided in the wiki's example will cause an error immediately.

[ManagedPoolThread #15] WARN JetBrains.Container.Log4netDefaultLoggerInitializer - Unhandled exception in current domain: System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain., , (null)

This error causes TeamCity's DotCover code coverage to hang indefinitely as well.
This only occurs in TeamCity, and runs perfectly fine if I use NUnit from the official source, as well as using ReSharper in Visual Studio to run the Tests.

It will be good if anyone has any solution, otherwise I am going to try using an external runner.
http://www.tellingmachine.com/post/Running-NUnit-tests-externally-without-a-TeamCity-agent-and-synchronizing-execution-time-and-test-results-with-a-TeamCity-build.aspx
Then somehow use the provided Code Coverage tool in TeamCity as well.

Wish: Add support of versioned/unversioned fields with a type

In current implementation it is not possible to versioned/unversioned field with a type. The only available syntax for adding versioned field is:

new DbField("Title")
{
  { "en", 1, "Hello!" },
  { "en", 2, "Welcome!" }
}

I suggest to add DbVersion:

new DbItem("MyItem")
{
  new DbVersion("en") // for unversioned fields
  {
    new DbField("UnversionedLink") { Value = someId.ToString(), Type = "droptree", Shared = false },
  },
  new DbVersion("en", 4) // for versioned fields
  {
    new DbField("VersionedLink") { Value = someId.ToString(), Type = "droptree", Shared = false },
  }
}

and/or extend original syntax:

new DbField("VersionedLink")
{
  { "en", 4, someId.ToString(), "droptree" },
},
new DbField("UnversionedLink")
{
  { "en", someId.ToString(), "droptree" },
}

Standard Template should return empty `BaseTemplates` collection

The util method below calls the template's BaseTemplates property recursively. At the moment the Standard Template has returns itself when the BaseTemplates is called so the code fails with the StackOverflowException:

private static bool IsTemplateDescendant(TemplateItem templateItem, ID template)
{
  if (templateItem == null || template == (ID)null)
  {
    return false;
  }

  if (templateItem.ID == template)
  {
    return true;
  }

  return templateItem.BaseTemplates.Any(baseTemplate => IsTemplateDescendant(baseTemplate, template));
}

Standard Template should return empty BaseTemplates collection.

Automatic template generation needs to be a little smarter

FakeDb will generate a template for a DbItem that was not given a specific template. FakeDb also reuses the template from the sibling item added previously in case item definitions match (i.e. same fields). I believe FakeDb shouldn't reuse templates unless those were auto-generated. Here's an example:

using (var db = new Db
{
    new DbTemplate("Site Root", new ID(myID),
    new DbItem("site", ID.NewID, new ID(myID))
    {
        new DbItem("home")
    },
    new DbItem("outside")
})
{
    var home = db.GetItem("/sitecore/content/site/home");
    var outside = db.GetItem("/sitecore/content/outside");

    outside.TemplateID.Should().NotBe(myID) // <-- Fails
}

outside item will be created with myID as its TemplateID. I think it should have been given its own template.

@sergeyshushlyapin , let me know what you think. I will send a pull request shortly :)

Include configs

Does FakeDb make use of Sitecore Include config files? I want to separate out my config changes for my testing from the main App.config.

Links Table

Does FakeDB update the links table? I am trying to test referrers and referenced.

Wish: Add default field types to app.config

It would be really handy if there is a support of all existing field types out of the box.

<fieldTypes>
  <fieldType name="Checkbox" type="Sitecore.Data.Fields.CheckboxField,Sitecore.Kernel" />
  <fieldType name="Checklist" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Custom" type="Sitecore.Data.Fields.CustomCustomField,Sitecore.Kernel" />
  <fieldType name="Datasource" type="Sitecore.Data.Fields.DatasourceField,Sitecore.Kernel" />
  <fieldType name="Date" type="Sitecore.Data.Fields.DateField,Sitecore.Kernel" />
  <fieldType name="Datetime" type="Sitecore.Data.Fields.DateField,Sitecore.Kernel" />
  <fieldType name="Droplink" type="Sitecore.Data.Fields.LookupField,Sitecore.Kernel" />
  <fieldType name="Droplist" type="Sitecore.Data.Fields.ValueLookupField,Sitecore.Kernel" />
  <fieldType name="Droptree" type="Sitecore.Data.Fields.ReferenceField,Sitecore.Kernel" />
  <fieldType name="File" type="Sitecore.Data.Fields.FileField,Sitecore.Kernel" />
  <fieldType name="File Drop Area" type="Sitecore.Data.Fields.FileDropAreaField,Sitecore.Kernel" />
  <fieldType name="Frame" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" resizable="true" />
  <fieldType name="General Link" type="Sitecore.Data.Fields.LinkField,Sitecore.Kernel" />
  <fieldType name="General Link with Search" type="Sitecore.Data.Fields.LinkField,Sitecore.Kernel" />
  <fieldType name="Grouped Droplink" type="Sitecore.Data.Fields.GroupedDroplinkField,Sitecore.Kernel" />
  <fieldType name="Grouped Droplist" type="Sitecore.Data.Fields.GroupedDroplistField,Sitecore.Kernel" />
  <fieldType name="html" type="Sitecore.Data.Fields.HtmlField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Image" type="Sitecore.Data.Fields.ImageField,Sitecore.Kernel" />
  <fieldType name="Internal Link" type="Sitecore.Data.Fields.InternalLinkField,Sitecore.Kernel" />
  <fieldType name="Layout" type="Sitecore.Data.Fields.LayoutField,Sitecore.Kernel" />
  <fieldType name="link" type="Sitecore.Data.Fields.LinkField,Sitecore.Kernel" />
  <fieldType name="lookup" type="Sitecore.Data.Fields.LookupField,Sitecore.Kernel" />
  <fieldType name="memo" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Multi-Line Text" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Multilist" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Multilist with Search" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Name Value List" type="Sitecore.Data.Fields.NameValueListField,Sitecore.Kernel" />
  <fieldType name="Page Preview" type="Sitecore.Data.Fields.PagePreviewField,Sitecore.Kernel" />
  <fieldType name="reference" type="Sitecore.Data.Fields.ReferenceField,Sitecore.Kernel" />
  <fieldType name="Rendering Datasource" type="Sitecore.Data.Fields.RenderingDatasourceField,Sitecore.Kernel" />
  <fieldType name="Rich Text" type="Sitecore.Data.Fields.HtmlField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Rules" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Security" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" resizable="true" />
  <fieldType name="Single-Line Text" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" />
  <fieldType name="Template Field Source" type="Sitecore.Data.Fields.TemplateFieldSourceField,Sitecore.Kernel" />
  <fieldType name="text" type="Sitecore.Data.Fields.TextField,Sitecore.Kernel" />
  <fieldType name="Thumbnail" type="Sitecore.Data.Fields.ThumbnailField,Sitecore.Kernel" />
  <fieldType name="tree" type="Sitecore.Data.Fields.ReferenceField,Sitecore.Kernel" />
  <fieldType name="tree list" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />
  <fieldType name="Treelist" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />
  <fieldType name="Treelist with Search" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />
  <fieldType name="TreelistEx" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />
  <fieldType name="valuelookup" type="Sitecore.Data.Fields.ValueLookupField,Sitecore.Kernel" />
  <fieldType name="Version Link" type="Sitecore.Data.Fields.VersionLinkField,Sitecore.Kernel" />
  <fieldType name="Word Document" type="Sitecore.Data.Fields.WordDocumentField,Sitecore.Kernel" blob="true" />
</fieldTypes>

What is the purpose of disposing Db object?

The Db class implements IDisposable interface and in examples this object is always gets disposed via using statement.

Question: Is there any negative consequences in leaving Db object indisposed?

The reason of this question is shorting the syntax and improving code style from

using(var db = new Db {
  new DbItem("test") { 
    new DbField("field") { Value = "value" } } })
{
  var test = db.GetItem("/sitecore/content/test");
  Assert.IsNotNull(test);
}

to

var db = new Db {
  new DbItem("test") { 
      new DbField("field") { Value = "value" } } };

var test = db.GetItem("/sitecore/content/test");
Assert.IsNotNull(test);

Glass Mapper

Hi,

I am using Glass Mapper, and would like to map Rich Text editor string fields by using
item.GlassCast()

I am getting a mapping error because obviously there is no proper SitecoreContext.
Any ideas on how to get around this by any chance ?

I have tried following the steps here but it did not work.
Glass-lu/Glass.Sitecore.Mapper#38

Implement db.GetEnumerator()

The db.GetEnumerator() method throws NotImplementedException which prevents AutoFixture from instantiating a new db instance. The code bellow should not fail:

[Theory, AutoData]
public void ShouldCreateDb(Db db)
{
  // arrange
  db.Add(new DbItem("home"));

  // act & assert
  db.GetItem("/sitecore/content/home").Should().NotBeNull();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.