-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#357) MappedProperty: should produce the current value on Advise
- Loading branch information
Showing
2 changed files
with
32 additions
and
3 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
30 changes: 30 additions & 0 deletions
30
rd-net/Test.Lifetimes/Collections/Viewable/ViewablePropertyTest.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,30 @@ | ||
using JetBrains.Collections.Viewable; | ||
using JetBrains.Lifetimes; | ||
using NUnit.Framework; | ||
|
||
namespace Test.Lifetimes.Collections.Viewable; | ||
|
||
public class ViewablePropertyTest | ||
{ | ||
[TestCase] | ||
public void TestAdvise() | ||
{ | ||
var prop = new ViewableProperty<int>(123); | ||
Lifetime.Using(lt => | ||
{ | ||
int? value = null; | ||
prop.Advise(lt, x => value = x); | ||
Assert.AreEqual(123, value); | ||
}); | ||
Lifetime.Using(lt => | ||
{ | ||
int? value = null; | ||
var mapped = prop.Select(x => x + 1); | ||
mapped.Advise(lt, x => value = x); | ||
Assert.AreEqual(124, value); | ||
prop.Value = 125; | ||
Assert.AreEqual(126, value); | ||
}); | ||
} | ||
} |