-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new File, Image, User content types (#123)
- Loading branch information
Showing
6 changed files
with
140 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -988,6 +988,61 @@ public async Task Repository_T_RegisterGlobalContentType_TypeAndDifferentName() | |
Assert.AreEqual(typeof(MyContent), contentType); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Repository_T_RegisterGlobalContentType_BuiltIn_User() | ||
{ | ||
// ALIGN | ||
var restCaller = CreateRestCallerFor(@" | ||
{ | ||
""d"": { | ||
""Id"": 1, | ||
""Path"": ""/Root/IMS/BuiltIn/Admin"", | ||
""Name"": ""Admin"", | ||
""Type"": ""User"", | ||
""LoginName"": ""admin"", | ||
""Email"": ""[email protected]"", | ||
""BirthDate"": ""2000-02-03T00:00:00Z"", | ||
""Avatar"": { | ||
""Url"": ""/Root/Content/images/avatar.png"" | ||
}, | ||
""ImageRef"": { | ||
""Id"": 123, | ||
""Path"": ""/Root/Content/images/avatar.png"", | ||
""Type"": ""Image"", | ||
""Name"": ""avatar.png"", | ||
""DateTaken"": ""2010-10-01T00:00:00Z"", | ||
""Width"": 456, | ||
""Height"": 789 | ||
} | ||
} | ||
}"); | ||
|
||
var repositories = GetRepositoryCollection(services => | ||
{ | ||
services.AddSingleton(restCaller); | ||
}); | ||
|
||
var repository = await repositories.GetRepositoryAsync(FakeServer, CancellationToken.None) | ||
.ConfigureAwait(false); | ||
|
||
// ACT | ||
var user = await repository.LoadContentAsync<User>("/testcontentpath", CancellationToken.None); | ||
|
||
// ASSERT | ||
Assert.IsNotNull(user); | ||
Assert.AreEqual(typeof(User), user.GetType()); | ||
Assert.AreEqual("Admin", user.Name); | ||
Assert.AreEqual("admin", user.LoginName); | ||
Assert.AreEqual("[email protected]", user.Email); | ||
Assert.AreEqual(new DateTime(2000, 02, 03, 0, 0, 0, DateTimeKind.Utc), user.BirthDate); | ||
|
||
Assert.AreEqual(typeof(Image), user.ImageRef.GetType()); | ||
Assert.AreEqual(123, user.ImageRef.Id); | ||
Assert.AreEqual(456, user.ImageRef.Width); | ||
Assert.AreEqual(789, user.ImageRef.Height); | ||
Assert.AreEqual("/Root/Content/images/avatar.png", user.Avatar.Url); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Repository_T_RegisterContentTypes() | ||
{ | ||
|
@@ -1014,7 +1069,7 @@ public async Task Repository_T_RegisterContentTypes() | |
var repositoryAcc = new ObjectAccessor(repository); | ||
var services = (IServiceProvider)repositoryAcc.GetField("_services"); | ||
Assert.AreEqual(ExampleUrl, repository.Server.Url); | ||
Assert.AreEqual(0, repository.GlobalContentTypes.ContentTypes.Count); | ||
Assert.AreEqual(3, repository.GlobalContentTypes.ContentTypes.Count); | ||
var contentTypeRegistrations = repository.Server.RegisteredContentTypes.ContentTypes | ||
.OrderBy(x => x.Value.Name) | ||
.ToArray(); | ||
|
@@ -1067,7 +1122,7 @@ public async Task Repository_T_RegisterContentTypes_DifferentTypeSameName() | |
// ASSERT | ||
// check repo1 | ||
Assert.AreEqual(ExampleUrl, repository1.Server.Url); | ||
Assert.AreEqual(0, repository1.GlobalContentTypes.ContentTypes.Count); | ||
Assert.AreEqual(3, repository1.GlobalContentTypes.ContentTypes.Count); | ||
var contentTypeRegistrations1 = repository1.Server.RegisteredContentTypes.ContentTypes | ||
.OrderBy(x => x.Value.Name) | ||
.ToArray(); | ||
|
@@ -1077,7 +1132,7 @@ public async Task Repository_T_RegisterContentTypes_DifferentTypeSameName() | |
|
||
// check repo2 | ||
Assert.AreEqual(exampleUrl2, repository2.Server.Url); | ||
Assert.AreEqual(0, repository2.GlobalContentTypes.ContentTypes.Count); | ||
Assert.AreEqual(3, repository2.GlobalContentTypes.ContentTypes.Count); | ||
var contentTypeRegistrations2 = repository2.Server.RegisteredContentTypes.ContentTypes | ||
.OrderBy(x => x.Value.Name) | ||
.ToArray(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace SenseNet.Client | ||
{ | ||
/// <summary> | ||
/// Represents a file in the sensenet repository. | ||
/// </summary> | ||
public class File : Content | ||
{ | ||
public File(IRestCaller restCaller, ILogger<File> logger) : base(restCaller, logger) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace SenseNet.Client | ||
{ | ||
/// <summary> | ||
/// Represents an image in the sensenet repository. | ||
/// </summary> | ||
public class Image : File | ||
{ | ||
public int Width { get; set; } | ||
public int Height { get; set; } | ||
public DateTime DateTaken { get; set; } | ||
|
||
public Image(IRestCaller restCaller, ILogger<Image> logger) : base(restCaller, logger) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace SenseNet.Client | ||
{ | ||
/// <summary> | ||
/// Represents a user in the sensenet repository. | ||
/// </summary> | ||
public class User : Content | ||
{ | ||
public User(IRestCaller restCaller, ILogger<Content> logger) : base(restCaller, logger) | ||
{ | ||
} | ||
|
||
public string LoginName { get; set; } | ||
public string DisplayName { get; set; } | ||
public string JobTitle { get; set; } | ||
public bool Enabled { get; set; } | ||
public string Domain { get; set; } | ||
public string Email { get; set; } | ||
public string FullName { get; set; } | ||
public Image ImageRef { get; set; } | ||
public Avatar Avatar { get; set; } | ||
public DateTime LastSync { get; set; } | ||
public User Manager { get; set; } | ||
public string Department { get; set; } | ||
public string Languages { get; set; } | ||
public string Phone { get; set; } | ||
public DateTime BirthDate { get; set; } | ||
public string TwitterAccount { get; set; } | ||
public string FacebookURL { get; set; } | ||
public string LinkedInURL { get; set; } | ||
public string ProfilePath { get; set; } | ||
public bool MultiFactorEnabled { get; set; } | ||
} | ||
|
||
public class Avatar | ||
{ | ||
public string Url { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters