* It builds.. * Added granular permissions * Added granular permissions * Rename content to document * Added migration * Fixed issues causing the migration from v13 was not possible. * Merged Permissions and Granular Permissions in viewmodel * Prepared the viewmodel to a future where permissions can be more types. * OpenApi * Allow to translate a single char to many strings * Use frontend friendly values for known permissions * Validate the documents exist * Allow setting non-document settings * Add "$type" when required * Rename to presentation model and update OpenApi.json * OpenApi.json * Fix tests * OpenAPI * Fixed issues with upgrades * Add the discriminator name * Fixed issues that only happended on SqlServer * Fixed queries for SqlServer * Clean up * More cleanup * Fix issue when migrating sqlserver * Split fallback permissions into own concept in view model * Also split on current user * Added a extenable pattern for mappers between DTO => Granular Permission => ViewModel and ViewModel => Granular Permission * Fixed issue with new exists method, that did not take duplicate keys into account. * Added sections to current user response model * Formatting fixes * Move class to its own file * xml comment --------- Co-authored-by: Zeegaan <skrivdetud@gmail.com>
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
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 UserGroupBuilderTests
|
|
{
|
|
[Test]
|
|
public void Is_Built_Correctly()
|
|
{
|
|
// Arrange
|
|
const int testId = 10;
|
|
const string testAlias = "test";
|
|
const string testName = "Test";
|
|
const int testUserCount = 11;
|
|
const string testIcon = "icon";
|
|
ISet<string> testPermissions = "abc".Select(x=>x.ToString()).ToHashSet();
|
|
const int testStartContentId = 3;
|
|
const int testStartMediaId = 8;
|
|
|
|
var builder = new UserGroupBuilder();
|
|
|
|
// Act
|
|
var userGroup = builder
|
|
.WithId(testId)
|
|
.WithAlias(testAlias)
|
|
.WithName(testName)
|
|
.WithUserCount(testUserCount)
|
|
.WithIcon(testIcon)
|
|
.WithPermissions(testPermissions)
|
|
.WithStartContentId(testStartContentId)
|
|
.WithStartMediaId(testStartMediaId)
|
|
.Build();
|
|
|
|
// Assert
|
|
Assert.AreEqual(testId, userGroup.Id);
|
|
Assert.AreEqual(testAlias, userGroup.Alias);
|
|
Assert.AreEqual(testName, userGroup.Name);
|
|
Assert.AreEqual(testUserCount, userGroup.UserCount);
|
|
Assert.AreEqual(testIcon, userGroup.Icon);
|
|
Assert.AreEqual(testPermissions.Count, userGroup.Permissions.Count());
|
|
Assert.AreEqual(testStartContentId, userGroup.StartContentId);
|
|
Assert.AreEqual(testStartMediaId, userGroup.StartMediaId);
|
|
}
|
|
}
|