Skip to content

Commit

Permalink
Content creation #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kavics committed Feb 23, 2023
1 parent a3fdbcd commit fa6e422
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/SenseNet.Client.Tests/RepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public async Task Repository_CreateContent_DifferentTypeSameName()
Assert.IsInstanceOfType(content2, typeof(DifferentNamespace.MyContent));
}
[TestMethod]
public async Task Repository_CreateContent_Unknown()
public async Task Repository_CreateContent_Unknown_ByType()
{
var repositoryService = GetRepositoryService();
var repository = await repositoryService.GetRepositoryAsync(CancellationToken.None)
Expand All @@ -377,6 +377,27 @@ public async Task Repository_CreateContent_Unknown()
Assert.IsTrue(exception.Message.Contains(nameof(MyContent)));
Assert.IsNotNull(exception.InnerException, "The exception.InnerException is null");
}
[TestMethod]
public async Task Repository_CreateContent_Unknown_ByName()
{
var repositoryService = GetRepositoryService();
var repository = await repositoryService.GetRepositoryAsync(CancellationToken.None)
.ConfigureAwait(false);
Exception exception = null;

// ACTION
try
{
var content = repository.CreateContent(nameof(MyContent));
// ASSERT
Assert.Fail($"The expected {nameof(ApplicationException)} was not thrown.");
}
catch (ApplicationException e)
{
exception = e;
}
Assert.IsTrue(exception.Message.Contains(nameof(MyContent)));
}

/* =================================================================== LOAD CONTENT */

Expand Down
2 changes: 1 addition & 1 deletion src/SenseNet.Client/Repository/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public T CreateContent<T>() where T : Content
}
catch (InvalidOperationException ex)
{
throw new ApplicationException("The content type is not registered: " + typeof(T).Name);
throw new ApplicationException("The content type is not registered: " + typeof(T).Name, ex);
}
}

Expand Down

0 comments on commit fa6e422

Please sign in to comment.