1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . Threading . Tasks ;
4
- using k8s ;
5
- using k8s . Models ;
6
- using KubeOps . Operator . Queue ;
7
-
8
- namespace KubeOps . Testing
1
+ namespace KubeOps . Testing
9
2
{
10
3
/// <summary>
11
4
/// Mocked resource event queue.
@@ -18,99 +11,99 @@ namespace KubeOps.Testing
18
11
/// queue.Created(new V1TestEntity());
19
12
/// </example>
20
13
/// <typeparam name="TEntity"></typeparam>
21
- public class MockResourceEventQueue < TEntity > : IResourceEventQueue < TEntity >
22
- where TEntity : IKubernetesObject < V1ObjectMeta >
23
- {
24
- private readonly MockResourceQueueCollection _collection ;
25
-
26
- public MockResourceEventQueue ( MockResourceQueueCollection collection )
27
- {
28
- _collection = collection ;
29
- }
30
-
31
- /// <inheritdoc />
32
- public event EventHandler < ( ResourceEventType Type , TEntity Resource ) > ? ResourceEvent ;
33
-
34
- /// <summary>
35
- /// List of enqueued entities.
36
- /// </summary>
37
- public IList < TEntity > Enqueued { get ; } = new List < TEntity > ( ) ;
38
-
39
- /// <summary>
40
- /// List of enqueued errors.
41
- /// </summary>
42
- public IList < ( ResourceEventType Type , TEntity Resource ) > ErrorEnqueued { get ; } =
43
- new List < ( ResourceEventType , TEntity ) > ( ) ;
44
-
45
- public void Dispose ( )
46
- {
47
- }
48
-
49
- /// <inheritdoc />
50
- public Task Start ( )
51
- {
52
- _collection . Register ( this ) ;
53
- return Task . CompletedTask ;
54
- }
55
-
56
- /// <inheritdoc />
57
- public Task Stop ( )
58
- {
59
- _collection . Unregister ( this ) ;
60
- return Task . CompletedTask ;
61
- }
62
-
63
- /// <summary>
64
- /// Fire a (mocked) <see cref="ResourceEventType.Created"/> event.
65
- /// </summary>
66
- /// <param name="entity">The entity that fires the event.</param>
67
- public void Created ( TEntity entity ) => Fire ( ResourceEventType . Created , entity ) ;
68
-
69
- /// <summary>
70
- /// Fire a (mocked) <see cref="ResourceEventType.Updated"/> event.
71
- /// </summary>
72
- /// <param name="entity">The entity that fires the event.</param>
73
- public void Updated ( TEntity entity ) => Fire ( ResourceEventType . Updated , entity ) ;
74
-
75
- /// <summary>
76
- /// Fire a (mocked) <see cref="ResourceEventType.Deleted"/> event.
77
- /// </summary>
78
- /// <param name="entity">The entity that fires the event.</param>
79
- public void Deleted ( TEntity entity ) => Fire ( ResourceEventType . Deleted , entity ) ;
80
-
81
- /// <summary>
82
- /// Fire a (mocked) <see cref="ResourceEventType.NotModified"/> event.
83
- /// </summary>
84
- /// <param name="entity">The entity that fires the event.</param>
85
- public void NotModified ( TEntity entity ) => Fire ( ResourceEventType . NotModified , entity ) ;
86
-
87
- /// <summary>
88
- /// Fire a (mocked) <see cref="ResourceEventType.StatusUpdated"/> event.
89
- /// </summary>
90
- /// <param name="entity">The entity that fires the event.</param>
91
- public void StatusUpdated ( TEntity entity ) => Fire ( ResourceEventType . StatusUpdated , entity ) ;
92
-
93
- /// <summary>
94
- /// Fire a (mocked) <see cref="ResourceEventType.Finalizing"/> event.
95
- /// </summary>
96
- /// <param name="entity">The entity that fires the event.</param>
97
- public void Finalizing ( TEntity entity ) => Fire ( ResourceEventType . Finalizing , entity ) ;
98
-
99
- /// <inheritdoc />
100
- public Task Enqueue ( TEntity resource , TimeSpan ? enqueueDelay = null )
101
- {
102
- Enqueued . Add ( resource ) ;
103
- return Task . CompletedTask ;
104
- }
105
-
106
- /// <inheritdoc />
107
- public void EnqueueErrored ( ResourceEventType type , TEntity resource ) => ErrorEnqueued . Add ( ( type , resource ) ) ;
108
-
109
- /// <inheritdoc />
110
- public void ClearError ( TEntity resource )
111
- {
112
- }
113
-
114
- private void Fire ( ResourceEventType type , TEntity entity ) => ResourceEvent ? . Invoke ( this , ( type , entity ) ) ;
115
- }
14
+ // public class MockResourceEventQueue<TEntity> : IResourceEventQueue<TEntity>
15
+ // where TEntity : IKubernetesObject<V1ObjectMeta>
16
+ // {
17
+ // private readonly MockResourceQueueCollection _collection;
18
+ //
19
+ // public MockResourceEventQueue(MockResourceQueueCollection collection)
20
+ // {
21
+ // _collection = collection;
22
+ // }
23
+ //
24
+ // /// <inheritdoc />
25
+ // public event EventHandler<(ResourceEventType Type, TEntity Resource)>? ResourceEvent;
26
+ //
27
+ // /// <summary>
28
+ // /// List of enqueued entities.
29
+ // /// </summary>
30
+ // public IList<TEntity> Enqueued { get; } = new List<TEntity>();
31
+ //
32
+ // /// <summary>
33
+ // /// List of enqueued errors.
34
+ // /// </summary>
35
+ // public IList<(ResourceEventType Type, TEntity Resource)> ErrorEnqueued { get; } =
36
+ // new List<(ResourceEventType, TEntity)>();
37
+ //
38
+ // public void Dispose()
39
+ // {
40
+ // }
41
+ //
42
+ // /// <inheritdoc />
43
+ // public Task Start()
44
+ // {
45
+ // _collection.Register(this);
46
+ // return Task.CompletedTask;
47
+ // }
48
+ //
49
+ // /// <inheritdoc />
50
+ // public Task Stop()
51
+ // {
52
+ // _collection.Unregister(this);
53
+ // return Task.CompletedTask;
54
+ // }
55
+ //
56
+ // /// <summary>
57
+ // /// Fire a (mocked) <see cref="ResourceEventType.Created"/> event.
58
+ // /// </summary>
59
+ // /// <param name="entity">The entity that fires the event.</param>
60
+ // public void Created(TEntity entity) => Fire(ResourceEventType.Created, entity);
61
+ //
62
+ // /// <summary>
63
+ // /// Fire a (mocked) <see cref="ResourceEventType.Updated"/> event.
64
+ // /// </summary>
65
+ // /// <param name="entity">The entity that fires the event.</param>
66
+ // public void Updated(TEntity entity) => Fire(ResourceEventType.Updated, entity);
67
+ //
68
+ // /// <summary>
69
+ // /// Fire a (mocked) <see cref="ResourceEventType.Deleted"/> event.
70
+ // /// </summary>
71
+ // /// <param name="entity">The entity that fires the event.</param>
72
+ // public void Deleted(TEntity entity) => Fire(ResourceEventType.Deleted, entity);
73
+ //
74
+ // /// <summary>
75
+ // /// Fire a (mocked) <see cref="ResourceEventType.NotModified"/> event.
76
+ // /// </summary>
77
+ // /// <param name="entity">The entity that fires the event.</param>
78
+ // public void NotModified(TEntity entity) => Fire(ResourceEventType.NotModified, entity);
79
+ //
80
+ // /// <summary>
81
+ // /// Fire a (mocked) <see cref="ResourceEventType.StatusUpdated"/> event.
82
+ // /// </summary>
83
+ // /// <param name="entity">The entity that fires the event.</param>
84
+ // public void StatusUpdated(TEntity entity) => Fire(ResourceEventType.StatusUpdated, entity);
85
+ //
86
+ // /// <summary>
87
+ // /// Fire a (mocked) <see cref="ResourceEventType.Finalizing"/> event.
88
+ // /// </summary>
89
+ // /// <param name="entity">The entity that fires the event.</param>
90
+ // public void Finalizing(TEntity entity) => Fire(ResourceEventType.Finalizing, entity);
91
+ //
92
+ // /// <inheritdoc />
93
+ // public Task Enqueue(TEntity resource, TimeSpan? enqueueDelay = null)
94
+ // {
95
+ // Enqueued.Add(resource);
96
+ // return Task.CompletedTask;
97
+ // }
98
+ //
99
+ // /// <inheritdoc />
100
+ // public void EnqueueErrored(ResourceEventType type, TEntity resource) => ErrorEnqueued.Add((type, resource));
101
+ //
102
+ // /// <inheritdoc />
103
+ // public void ClearError(TEntity resource)
104
+ // {
105
+ // }
106
+ //
107
+ // private void Fire(ResourceEventType type, TEntity entity) => ResourceEvent?.Invoke(this, (type, entity));
108
+ // }
116
109
}
0 commit comments