Dreamine.FullKit.Wpf.Tests
1.0.0.0
Dreamine.FullKit.Wpf.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
BehaviorTests.cs
이 파일의 문서화 페이지로 가기
1
using
System.Windows;
2
using
Dreamine.MVVM.Behaviors.Core.Base;
3
using
Dreamine.MVVM.Behaviors.Core.Interfaces;
4
using
Dreamine.MVVM.Behaviors.Wpf.Interactivity;
5
6
namespace
Dreamine.FullKit.Wpf.Tests.Behaviors
;
7
16
public
sealed
class
BehaviorTests
17
{
26
[Fact]
27
public
void
Behavior_AttachAndDetachUpdateAssociatedObjectAndHooks
()
28
{
29
var target =
new
DependencyObject();
30
var behavior =
new
TestBehavior
();
31
32
behavior.Attach(target);
33
34
Assert.Same(target, behavior.AssociatedObject);
35
Assert.Equal(1, behavior.AttachedCount);
36
37
behavior.Detach();
38
39
Assert.Null(behavior.AssociatedObject);
40
Assert.Equal(1, behavior.DetachedCount);
41
}
42
51
[Fact]
52
public
void
BehaviorCollection_AttachesAndDetachesChildBehaviors
()
53
{
54
var target =
new
DependencyObject();
55
var behavior =
new
TestCollectionBehavior
();
56
var collection =
new
BehaviorCollection { behavior };
57
58
collection.Attach(target);
59
collection.Detach();
60
61
Assert.Equal(1, behavior.AttachedCount);
62
Assert.Equal(1, behavior.DetachedCount);
63
}
64
73
[Fact]
74
public
void
BehaviorCollection_AttachesGenericAttachedObjectsThroughSingleContract
()
75
{
76
var target =
new
DependencyObject();
77
var behavior =
new
TestBehavior
();
78
var collection =
new
BehaviorCollection { behavior };
79
80
collection.Attach(target);
81
collection.Detach();
82
83
Assert.Equal(1, behavior.AttachedCount);
84
Assert.Equal(1, behavior.DetachedCount);
85
}
86
95
[Fact]
96
public
void
Interaction_GetBehaviorsCreatesEmptyCollectionWithoutDefaultBehavior
()
97
{
98
var target =
new
DependencyObject();
99
100
BehaviorCollection collection = Interaction.GetBehaviors(target);
101
102
Assert.Empty(collection);
103
Assert.DoesNotContain(collection, item => item is WindowDragBehavior);
104
Assert.Same(collection, Interaction.GetBehaviors(target));
105
}
106
115
[Fact]
116
public
void
Interaction_SetBehaviorsAttachesExplicitCollection
()
117
{
118
var target =
new
DependencyObject();
119
var behavior =
new
TestCollectionBehavior
();
120
var collection =
new
BehaviorCollection { behavior };
121
122
Interaction.SetBehaviors(target, collection);
123
124
Assert.Same(collection, Interaction.GetBehaviors(target));
125
Assert.Equal(1, behavior.AttachedCount);
126
}
127
136
private
sealed
class
TestBehavior
: Behavior<DependencyObject>
137
{
146
public
int
AttachedCount
{
get
;
private
set
; }
147
156
public
int
DetachedCount
{
get
;
private
set
; }
157
166
protected
override
void
OnAttached
()
167
{
168
AttachedCount
++;
169
}
170
179
protected
override
void
OnDetaching
()
180
{
181
DetachedCount
++;
182
}
183
}
184
193
private
sealed
class
TestCollectionBehavior
: DependencyObject, IBehavior
194
{
203
public
DependencyObject
AssociatedObject
{
get
;
private
set
; } =
null
!;
204
213
public
int
AttachedCount
{
get
;
private
set
; }
214
223
public
int
DetachedCount
{
get
;
private
set
; }
224
241
public
void
Attach
(DependencyObject dependencyObject)
242
{
243
AssociatedObject
= dependencyObject;
244
AttachedCount
++;
245
}
246
255
public
void
Detach
()
256
{
257
AssociatedObject
=
null
!;
258
DetachedCount
++;
259
}
260
}
261
}
Dreamine.FullKit.Wpf.Tests.Behaviors
Definition
BehaviorTests.cs:6
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests
Definition
BehaviorTests.cs:17
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.Interaction_SetBehaviorsAttachesExplicitCollection
void Interaction_SetBehaviorsAttachesExplicitCollection()
Definition
BehaviorTests.cs:116
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.Behavior_AttachAndDetachUpdateAssociatedObjectAndHooks
void Behavior_AttachAndDetachUpdateAssociatedObjectAndHooks()
Definition
BehaviorTests.cs:27
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.Interaction_GetBehaviorsCreatesEmptyCollectionWithoutDefaultBehavior
void Interaction_GetBehaviorsCreatesEmptyCollectionWithoutDefaultBehavior()
Definition
BehaviorTests.cs:96
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.BehaviorCollection_AttachesAndDetachesChildBehaviors
void BehaviorCollection_AttachesAndDetachesChildBehaviors()
Definition
BehaviorTests.cs:52
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.BehaviorCollection_AttachesGenericAttachedObjectsThroughSingleContract
void BehaviorCollection_AttachesGenericAttachedObjectsThroughSingleContract()
Definition
BehaviorTests.cs:74
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestBehavior
Definition
BehaviorTests.cs:137
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestBehavior.DetachedCount
int DetachedCount
Definition
BehaviorTests.cs:156
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestBehavior.AttachedCount
int AttachedCount
Definition
BehaviorTests.cs:146
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestBehavior.OnDetaching
override void OnDetaching()
Definition
BehaviorTests.cs:179
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestBehavior.OnAttached
override void OnAttached()
Definition
BehaviorTests.cs:166
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior
Definition
BehaviorTests.cs:194
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior.AssociatedObject
DependencyObject AssociatedObject
Definition
BehaviorTests.cs:203
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior.Attach
void Attach(DependencyObject dependencyObject)
Definition
BehaviorTests.cs:241
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior.AttachedCount
int AttachedCount
Definition
BehaviorTests.cs:213
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior.DetachedCount
int DetachedCount
Definition
BehaviorTests.cs:223
Dreamine.FullKit.Wpf.Tests.Behaviors.BehaviorTests.TestCollectionBehavior.Detach
void Detach()
Definition
BehaviorTests.cs:255
Behaviors
BehaviorTests.cs
다음에 의해 생성됨 :
1.17.0