* Adding TrackedReferencesController * Adding/changing views * Adding/Editing js files * RelationService changes * RelationRepository changes * Adding missing translations * Adding/Modifying tests * Beginning of #9125 migration * Introducing a new component + refactoring based on that * Abstracting + refactoring * Work on content unpublishing * Work on media.delete * Various small changes * Beginning of #9119 migration * Changes on content.delete * Various fixes * Adding new keys used in the listview bulk actions * Adding methods to get the items used in relations from array of ids * Adding the checkLinkedItems function to the trackedReferencesResource * Passing the selected items from a listview to unpublish and delete * Adding umb-tracked-references-listview * Adding umb-tracked-references-listview-table with language column * Fixes for tracked references * Changes in listview unpublish dialog * Changes in listview delete dialog * Removing Variants logic as it is not currently supported * Visual fixes * Closing dialogs on click * Fix wording * Fix breaking changes * Change to a single title "Items in use" instead of 2 different for Content and Media * No need for obsoleting because we can change new controllers * Return ActionResult from actions * V9: Prevent delete or unpublish of items that have references (#12047) * Introducing config settings that prevent delete or unpublish of items referenced by other items * Disable deletion of content items and show a new warning * Disable deletion of media items and show a new warning * Disable deletion of list view items * Disable unpublish and bulk unpublish * Add a new warning * V9: Displaying descendants in use as part of item tracking (#12039) * Replace HasReferencesInDescendants with GetPagedDescendantsInReferences * Display descendants in use on parent's info tab * Add getPagedDescendantsInReferences to trackedReferencesResource * Add lang keys for Descendants in use * Refactoring controller actions * Don't call check descendants usage when it is a new item * rename busfy to busy * always show references * rearrange for scrollbar to appear at the edge of the dialog * use the word referenced instead of used * change fallback texts * Added "IsDependency" to relation types * refactor of umb-tracked-references * rename checkLinkedItems to getPagedReferencedItems * rename check to load, to be consistent with the rest. * Refactored backend . Needs frontend fixes * Cleanup * Use filters * Front-end refactor to match refactored end-points * Fixed bug + warning * Fixed query (more then 2100 descensdants) and optimized it (using nested select instead of inner join). * remove comment * hideNoneDependencies including varying text for the configuration * Hack for SqlCE :( * some final adjustments for item tracking ui * Unbreak change Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Bjarke Berg <mail@bergmania.dk>
72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
|
using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Tests.Common.Builders
|
|
{
|
|
[TestFixture]
|
|
public class RelationBuilderTests
|
|
{
|
|
[Test]
|
|
public void Is_Built_Correctly()
|
|
{
|
|
// Arrange
|
|
const int parentId = 9;
|
|
const int childId = 8;
|
|
const int id = 4;
|
|
var key = Guid.NewGuid();
|
|
DateTime createDate = DateTime.Now.AddHours(-1);
|
|
DateTime updateDate = DateTime.Now;
|
|
const string comment = "test comment";
|
|
const int relationTypeId = 66;
|
|
const string relationTypeAlias = "test";
|
|
const string relationTypeName = "name";
|
|
var parentObjectType = Guid.NewGuid();
|
|
var childObjectType = Guid.NewGuid();
|
|
|
|
var builder = new RelationBuilder();
|
|
|
|
// Act
|
|
Relation relation = builder
|
|
.BetweenIds(parentId, childId)
|
|
.WithId(id)
|
|
.WithComment(comment)
|
|
.WithCreateDate(createDate)
|
|
.WithUpdateDate(updateDate)
|
|
.WithKey(key)
|
|
.AddRelationType()
|
|
.WithId(relationTypeId)
|
|
.WithAlias(relationTypeAlias)
|
|
.WithName(relationTypeName)
|
|
.WithIsBidirectional(false)
|
|
.WithIsDependency(true)
|
|
.WithParentObjectType(parentObjectType)
|
|
.WithChildObjectType(childObjectType)
|
|
.Done()
|
|
.Build();
|
|
|
|
// Assert
|
|
Assert.AreEqual(parentId, relation.ParentId);
|
|
Assert.AreEqual(childId, relation.ChildId);
|
|
Assert.AreEqual(id, relation.Id);
|
|
Assert.AreEqual(createDate, relation.CreateDate);
|
|
Assert.AreEqual(updateDate, relation.UpdateDate);
|
|
Assert.AreEqual(key, relation.Key);
|
|
Assert.AreEqual(comment, relation.Comment);
|
|
Assert.AreEqual(relationTypeId, relation.RelationType.Id);
|
|
Assert.AreEqual(relationTypeAlias, relation.RelationType.Alias);
|
|
Assert.AreEqual(relationTypeName, relation.RelationType.Name);
|
|
Assert.IsFalse(relation.RelationType.IsBidirectional);
|
|
|
|
Assert.IsTrue((relation.RelationType as IRelationTypeWithIsDependency).IsDependency);
|
|
Assert.AreEqual(parentObjectType, relation.RelationType.ParentObjectType);
|
|
Assert.AreEqual(childObjectType, relation.RelationType.ChildObjectType);
|
|
}
|
|
}
|
|
}
|