This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from leekelleher/hotfix-0.8.2
Fixes DittoConversionHandlerRegistry cache type-cast
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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
44 changes: 44 additions & 0 deletions
44
tests/Our.Umbraco.Ditto.Tests/MultipleConversionHandlerTests.cs
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,44 @@ | ||
namespace Our.Umbraco.Ditto.Tests | ||
{ | ||
using NUnit.Framework; | ||
using Our.Umbraco.Ditto.Tests.Mocks; | ||
|
||
[TestFixture] | ||
public class MultipleConversionHandlerTests | ||
{ | ||
public class MyModel | ||
{ | ||
public string Name { get; set; } | ||
} | ||
|
||
public class MyModelConversionHandler : DittoConversionHandler<MyModel> | ||
{ | ||
public override void OnConverted() | ||
{ | ||
Model.Name = "foo"; | ||
} | ||
} | ||
|
||
public class MyModelConversionHandler2 : DittoConversionHandler<MyModel> | ||
{ | ||
public override void OnConverted() | ||
{ | ||
Model.Name += " bar"; | ||
} | ||
} | ||
|
||
[Test] | ||
public void Multiple_Conversion_Handlers_Registered_Same_Type() | ||
{ | ||
Ditto.RegisterConversionHandler<MyModel, MyModelConversionHandler>(); | ||
Ditto.RegisterConversionHandler<MyModel, MyModelConversionHandler2>(); | ||
|
||
var content = new PublishedContentMock(); | ||
|
||
var model = content.As<MyModel>(); | ||
|
||
Assert.That(model, Is.Not.Null); | ||
Assert.That(model.Name, Is.EqualTo("foo bar")); | ||
} | ||
} | ||
} |
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