/src/Ninject.Extensions.Interception.Test/AutoNotifyPropertyClassProxyContext.cs
C# | 47 lines | 41 code | 6 blank | 0 comment | 0 complexity | ad45a1d30f5f0a7fcce9149b9fa9985f MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception
- namespace Ninject.Extensions.Interception
- {
- using FluentAssertions;
- using Ninject.Extensions.Interception.Fakes;
- using Xunit;
-
- public abstract class AutoNotifyPropertyClassProxyContext<TInterceptionModule>
- : AutoNotifyPropertyChangedContext<TInterceptionModule>
- where TInterceptionModule : InterceptionModule, new()
- {
- public AutoNotifyPropertyClassProxyContext()
- {
- this.ViewModel = this.Kernel.Get<ViewModelWithClassNotify>();
- this.ViewModel.PropertyChanged += (o, e) =>
- {
- LastPropertyToChange = e.PropertyName;
- PropertyChanges.Add(LastPropertyToChange);
- };
- }
- public ViewModelWithClassNotify ViewModel { get; set; }
- [Fact]
- public void WhenValueChangesOnPropertyWithoutNotifyAttribute_ItShouldNotifyChanges()
- {
- this.ViewModel.Address = "123 Main Street";
- LastPropertyToChange.Should().Be("Address");
- }
- [Fact]
- public void WhenValueChangesOnPropertyWithDependentProperties_ItShouldNotifyAllChanges()
- {
- this.ViewModel.ZipCode = 9700;
- PropertyChanges[0].Should().Be("ZipCode");
- PropertyChanges[1].Should().Be("City");
- PropertyChanges[2].Should().Be("State");
- }
- [Fact]
- public void WhenPropertyHasDoNotNotifyAttribute_ChangNotificationIsSuppressed()
- {
- this.ViewModel.DoNotNotifyChanges = "...";
- LastPropertyToChange.Should().BeNull();
- }
- }
- }