PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Ninject.Extensions.Interception.Test/AutoNotifyPropertyClassProxyContext.cs

https://github.com/hereyes/ninject.extensions.interception
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
  1. namespace Ninject.Extensions.Interception
  2. {
  3. using FluentAssertions;
  4. using Ninject.Extensions.Interception.Fakes;
  5. using Xunit;
  6. public abstract class AutoNotifyPropertyClassProxyContext<TInterceptionModule>
  7. : AutoNotifyPropertyChangedContext<TInterceptionModule>
  8. where TInterceptionModule : InterceptionModule, new()
  9. {
  10. public AutoNotifyPropertyClassProxyContext()
  11. {
  12. this.ViewModel = this.Kernel.Get<ViewModelWithClassNotify>();
  13. this.ViewModel.PropertyChanged += (o, e) =>
  14. {
  15. LastPropertyToChange = e.PropertyName;
  16. PropertyChanges.Add(LastPropertyToChange);
  17. };
  18. }
  19. public ViewModelWithClassNotify ViewModel { get; set; }
  20. [Fact]
  21. public void WhenValueChangesOnPropertyWithoutNotifyAttribute_ItShouldNotifyChanges()
  22. {
  23. this.ViewModel.Address = "123 Main Street";
  24. LastPropertyToChange.Should().Be("Address");
  25. }
  26. [Fact]
  27. public void WhenValueChangesOnPropertyWithDependentProperties_ItShouldNotifyAllChanges()
  28. {
  29. this.ViewModel.ZipCode = 9700;
  30. PropertyChanges[0].Should().Be("ZipCode");
  31. PropertyChanges[1].Should().Be("City");
  32. PropertyChanges[2].Should().Be("State");
  33. }
  34. [Fact]
  35. public void WhenPropertyHasDoNotNotifyAttribute_ChangNotificationIsSuppressed()
  36. {
  37. this.ViewModel.DoNotNotifyChanges = "...";
  38. LastPropertyToChange.Should().BeNull();
  39. }
  40. }
  41. }