* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
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 MemberGroupBuilderTests
|
|
{
|
|
[Test]
|
|
public void Is_Built_Correctly()
|
|
{
|
|
// Arrange
|
|
const int testId = 6;
|
|
const string testName = "Test Group";
|
|
const int testCreatorId = 4;
|
|
var testKey = Guid.NewGuid();
|
|
DateTime testCreateDate = DateTime.Now.AddHours(-1);
|
|
DateTime testUpdateDate = DateTime.Now;
|
|
var testAdditionalData1 = new KeyValuePair<string, object>("test1", 123);
|
|
var testAdditionalData2 = new KeyValuePair<string, object>("test2", "hello");
|
|
|
|
var builder = new MemberGroupBuilder();
|
|
|
|
// Act
|
|
MemberGroup group = builder
|
|
.WithId(testId)
|
|
.WithKey(testKey)
|
|
.WithName(testName)
|
|
.WithCreatorId(testCreatorId)
|
|
.WithCreateDate(testCreateDate)
|
|
.WithUpdateDate(testUpdateDate)
|
|
.AddAdditionalData()
|
|
.WithKeyValue(testAdditionalData1.Key, testAdditionalData1.Value)
|
|
.WithKeyValue(testAdditionalData2.Key, testAdditionalData2.Value)
|
|
.Done()
|
|
.Build();
|
|
|
|
// Assert
|
|
Assert.AreEqual(testId, group.Id);
|
|
Assert.AreEqual(testKey, group.Key);
|
|
Assert.AreEqual(testName, group.Name);
|
|
Assert.AreEqual(testCreateDate, group.CreateDate);
|
|
Assert.AreEqual(testUpdateDate, group.UpdateDate);
|
|
Assert.AreEqual(testCreatorId, group.CreatorId);
|
|
Assert.AreEqual(3, group.AdditionalData.Count); // previousName is added as part of the MemberGroup construction, plus the 2 we've added.
|
|
Assert.AreEqual(testAdditionalData1.Value, group.AdditionalData[testAdditionalData1.Key]);
|
|
Assert.AreEqual(testAdditionalData2.Value, group.AdditionalData[testAdditionalData2.Key]);
|
|
}
|
|
}
|
|
}
|