private void AssertDoesNotExists(DbItem item)
{
if (!this.FakeItems.ContainsKey(item.ID))
{
return;
}
var existingItem = this.FakeItems[item.ID];
string message;
if (existingItem is DbTemplate)
{
message = string.Format("A template with the same id has already been added ('{0}', '{1}').", item.ID, item.FullPath ?? item.Name);
}
else if (existingItem.GetType() == typeof(DbItem) && item is DbTemplate)
{
message = string.Format("Unable to create the item based on the template '{0}'. An item with the same id has already been added ('{1}').", item.ID, existingItem.FullPath);
}
else
{
message = string.Format("An item with the same id has already been added ('{0}', '{1}').", item.ID, item.FullPath);
}
throw new InvalidOperationException(message);
}