-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInterfacesTests.cs
More file actions
104 lines (85 loc) · 3.64 KB
/
InterfacesTests.cs
File metadata and controls
104 lines (85 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using NUnit.Framework;
using System.ComponentModel;
using DevExpress.Mvvm.CodeGenerators.MvvmLight;
using GalaSoft.MvvmLight;
namespace MvvmLight.Mvvm.Tests {
partial class SimpleClass { }
[GenerateViewModel]
partial class ClassWithGenerator { }
[GenerateViewModel(ImplementINotifyPropertyChanging = false)]
partial class NotImplementINPCing { }
[GenerateViewModel(ImplementINotifyPropertyChanging = true)]
partial class ImplementINPCing { }
[GenerateViewModel(ImplementICleanup = false)]
partial class NotImplementICU { }
[GenerateViewModel(ImplementICleanup = true)]
partial class ImplementICUParent { }
[GenerateViewModel(ImplementICleanup = true)]
partial class ImplementICUChild : ImplementICUParent { }
[GenerateViewModel(ImplementINotifyPropertyChanging = true,
ImplementICleanup = true)]
partial class FullImplemented : INotifyPropertyChanged, INotifyPropertyChanging, ICleanup{
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangingEventHandler PropertyChanging;
public void Cleanup() => throw new System.NotImplementedException();
}
[GenerateViewModel]
partial class ChildWithInheritedUserINPC : ViewModelBase { }
[GenerateViewModel(ImplementINotifyPropertyChanging = true)]
partial class GeneratedParent { }
[GenerateViewModel(ImplementINotifyPropertyChanging = true)]
partial class GeneratedChild : GeneratedParent {
[GenerateProperty]
int value;
}
[TestFixture]
public class IntefacesTests {
[Test]
public void INPCedImplimentation() {
var withGenerator = new ClassWithGenerator();
Assert.IsTrue(withGenerator is INotifyPropertyChanged);
var withoutGenerator = new SimpleClass();
Assert.IsTrue(withoutGenerator is not INotifyPropertyChanged);
}
[Test]
public void INPCingImplementation() {
var inpcingDefault = new ClassWithGenerator();
Assert.IsTrue(inpcingDefault is not INotifyPropertyChanging);
var inpcingImpl = new ImplementINPCing();
Assert.IsTrue(inpcingImpl is INotifyPropertyChanging);
var inpcingNotImpl = new NotImplementINPCing();
Assert.IsTrue(inpcingNotImpl is not INotifyPropertyChanging);
}
[Test]
public void DoubleImplementation() {
var fullImpl = new FullImplemented();
Assert.IsTrue(fullImpl is INotifyPropertyChanged);
Assert.IsTrue(fullImpl is INotifyPropertyChanging);
Assert.IsTrue(fullImpl is ICleanup);
}
[Test]
public void InheritanceUserINPC() {
var child = new ChildWithInheritedUserINPC();
Assert.IsTrue(child is INotifyPropertyChanged);
Assert.IsTrue(child is not INotifyPropertyChanging);
}
[Test]
public void InheritanceGeneratedINPC() {
var parent = new GeneratedParent();
var child = new GeneratedChild();
Assert.IsTrue(parent is INotifyPropertyChanged);
Assert.IsTrue(parent is INotifyPropertyChanging);
Assert.IsTrue(child is INotifyPropertyChanged);
Assert.IsTrue(child is INotifyPropertyChanging);
}
[Test]
public void ICUImplementation() {
var iaaDefault = new ClassWithGenerator();
Assert.IsTrue(iaaDefault is not ICleanup);
var parent = new ImplementICUParent();
var child = new ImplementICUChild();
Assert.IsTrue(parent is ICleanup);
Assert.IsTrue(child is ICleanup);
}
}
}