@@ -38,7 +38,91 @@ namespace MongoDB.Driver.Core.Operations
38
38
public class ChangeStreamOperationTests : OperationTestBase
39
39
{
40
40
[ Fact ]
41
- public void constructor_should_initialize_instance ( )
41
+ public void constructor_with_database_should_initialize_instance ( )
42
+ {
43
+ var databaseNamespace = new DatabaseNamespace ( "foo" ) ;
44
+ var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
45
+ var resultSerializer = BsonDocumentSerializer . Instance ;
46
+ var messageEncoderSettings = new MessageEncoderSettings ( ) ;
47
+
48
+ var subject = new ChangeStreamOperation < BsonDocument > ( databaseNamespace , pipeline , resultSerializer , messageEncoderSettings ) ;
49
+
50
+ subject . BatchSize . Should ( ) . NotHaveValue ( ) ;
51
+ subject . Collation . Should ( ) . BeNull ( ) ;
52
+ subject . CollectionNamespace . Should ( ) . BeNull ( ) ;
53
+ subject . DatabaseNamespace . Should ( ) . Be ( databaseNamespace ) ;
54
+ subject . FullDocument . Should ( ) . Be ( ChangeStreamFullDocumentOption . Default ) ;
55
+ subject . MaxAwaitTime . Should ( ) . NotHaveValue ( ) ;
56
+ subject . MessageEncoderSettings . Should ( ) . BeSameAs ( messageEncoderSettings ) ;
57
+ subject . Pipeline . Should ( ) . Equal ( pipeline ) ;
58
+ subject . ReadConcern . Should ( ) . Be ( ReadConcern . Default ) ;
59
+ subject . ResultSerializer . Should ( ) . BeSameAs ( resultSerializer ) ;
60
+ subject . ResumeAfter . Should ( ) . BeNull ( ) ;
61
+ subject . StartAtOperationTime . Should ( ) . BeNull ( ) ;
62
+ }
63
+
64
+ [ Fact ]
65
+ public void constructor_with_database_should_throw_when_databaseNamespace_is_null ( )
66
+ {
67
+ DatabaseNamespace databaseNamespace = null ;
68
+ var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
69
+ var resultSerializer = BsonDocumentSerializer . Instance ;
70
+ var messageEncoderSettings = new MessageEncoderSettings ( ) ;
71
+
72
+
73
+ var exception = Record . Exception ( ( ) => new ChangeStreamOperation < BsonDocument > ( databaseNamespace , pipeline , resultSerializer , messageEncoderSettings ) ) ;
74
+
75
+ var argumentNullException = exception . Should ( ) . BeOfType < ArgumentNullException > ( ) . Subject ;
76
+ argumentNullException . ParamName . Should ( ) . Be ( "databaseNamespace" ) ;
77
+ }
78
+
79
+ [ Fact ]
80
+ public void constructor_with_database_should_throw_when_pipeline_is_null ( )
81
+ {
82
+ var databaseNamespace = new DatabaseNamespace ( "foo" ) ;
83
+ var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
84
+ IBsonSerializer < BsonDocument > resultSerializer = null ;
85
+ var messageEncoderSettings = new MessageEncoderSettings ( ) ;
86
+
87
+
88
+ var exception = Record . Exception ( ( ) => new ChangeStreamOperation < BsonDocument > ( databaseNamespace , pipeline , resultSerializer , messageEncoderSettings ) ) ;
89
+
90
+ var argumentNullException = exception . Should ( ) . BeOfType < ArgumentNullException > ( ) . Subject ;
91
+ argumentNullException . ParamName . Should ( ) . Be ( "resultSerializer" ) ;
92
+ }
93
+
94
+ [ Fact ]
95
+ public void constructor_with_database_should_throw_when_messageEncoderSettings_is_null ( )
96
+ {
97
+ var databaseNamespace = new DatabaseNamespace ( "foo" ) ;
98
+ var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
99
+ var resultSerializer = BsonDocumentSerializer . Instance ;
100
+ MessageEncoderSettings messageEncoderSettings = null ;
101
+
102
+
103
+ var exception = Record . Exception ( ( ) => new ChangeStreamOperation < BsonDocument > ( databaseNamespace , pipeline , resultSerializer , messageEncoderSettings ) ) ;
104
+
105
+ var argumentNullException = exception . Should ( ) . BeOfType < ArgumentNullException > ( ) . Subject ;
106
+ argumentNullException . ParamName . Should ( ) . Be ( "messageEncoderSettings" ) ;
107
+ }
108
+
109
+ [ Fact ]
110
+ public void constructor_with_database_should_throw_when_resultSerializer_is_null ( )
111
+ {
112
+ var databaseNamespace = new DatabaseNamespace ( "foo" ) ;
113
+ List < BsonDocument > pipeline = null ;
114
+ var resultSerializer = BsonDocumentSerializer . Instance ;
115
+ var messageEncoderSettings = new MessageEncoderSettings ( ) ;
116
+
117
+
118
+ var exception = Record . Exception ( ( ) => new ChangeStreamOperation < BsonDocument > ( databaseNamespace , pipeline , resultSerializer , messageEncoderSettings ) ) ;
119
+
120
+ var argumentNullException = exception . Should ( ) . BeOfType < ArgumentNullException > ( ) . Subject ;
121
+ argumentNullException . ParamName . Should ( ) . Be ( "pipeline" ) ;
122
+ }
123
+
124
+ [ Fact ]
125
+ public void constructor_with_collection_should_initialize_instance ( )
42
126
{
43
127
var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
44
128
var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -50,17 +134,19 @@ public void constructor_should_initialize_instance()
50
134
subject . BatchSize . Should ( ) . NotHaveValue ( ) ;
51
135
subject . Collation . Should ( ) . BeNull ( ) ;
52
136
subject . CollectionNamespace . Should ( ) . BeSameAs ( collectionNamespace ) ;
137
+ subject . DatabaseNamespace . Should ( ) . BeNull ( ) ;
53
138
subject . FullDocument . Should ( ) . Be ( ChangeStreamFullDocumentOption . Default ) ;
54
139
subject . MaxAwaitTime . Should ( ) . NotHaveValue ( ) ;
55
140
subject . MessageEncoderSettings . Should ( ) . BeSameAs ( messageEncoderSettings ) ;
56
141
subject . Pipeline . Should ( ) . Equal ( pipeline ) ;
57
142
subject . ReadConcern . Should ( ) . Be ( ReadConcern . Default ) ;
58
143
subject . ResultSerializer . Should ( ) . BeSameAs ( resultSerializer ) ;
59
144
subject . ResumeAfter . Should ( ) . BeNull ( ) ;
145
+ subject . StartAtOperationTime . Should ( ) . BeNull ( ) ;
60
146
}
61
147
62
148
[ Fact ]
63
- public void constructor_should_throw_when_collectionNamespace_is_null ( )
149
+ public void constructor_with_collection_should_throw_when_collectionNamespace_is_null ( )
64
150
{
65
151
CollectionNamespace collectionNamespace = null ;
66
152
var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -75,7 +161,7 @@ public void constructor_should_throw_when_collectionNamespace_is_null()
75
161
}
76
162
77
163
[ Fact ]
78
- public void constructor_should_throw_when_pipeline_is_null ( )
164
+ public void constructor_with_collection_should_throw_when_pipeline_is_null ( )
79
165
{
80
166
var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
81
167
var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -90,7 +176,7 @@ public void constructor_should_throw_when_pipeline_is_null()
90
176
}
91
177
92
178
[ Fact ]
93
- public void constructor_should_throw_when_messageEncoderSettings_is_null ( )
179
+ public void constructor_with_collection_should_throw_when_messageEncoderSettings_is_null ( )
94
180
{
95
181
var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
96
182
var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -105,7 +191,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null()
105
191
}
106
192
107
193
[ Fact ]
108
- public void constructor_should_throw_when_resultSerializer_is_null ( )
194
+ public void constructor_with_collection_should_throw_when_resultSerializer_is_null ( )
109
195
{
110
196
var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
111
197
List < BsonDocument > pipeline = null ;
@@ -259,6 +345,20 @@ public void ResumeAfter_get_and_set_should_work(
259
345
result . Should ( ) . Be ( value ) ;
260
346
}
261
347
348
+ [ Theory ]
349
+ [ InlineData ( null , null ) ]
350
+ [ InlineData ( 1 , 2 ) ]
351
+ public void StartAtOperationTime_get_and_set_should_work ( int ? t , int ? i )
352
+ {
353
+ var subject = CreateSubject ( ) ;
354
+ var value = t . HasValue ? new BsonTimestamp ( t . Value , i . Value ) : null ;
355
+
356
+ subject . StartAtOperationTime = value ;
357
+ var result = subject . StartAtOperationTime ;
358
+
359
+ result . Should ( ) . Be ( value ) ;
360
+ }
361
+
262
362
[ SkippableTheory ]
263
363
[ ParameterAttributeData ]
264
364
public void Execute_should_return_expected_results_for_drop_collection (
0 commit comments