@@ -38,7 +38,91 @@ namespace MongoDB.Driver.Core.Operations
3838 public class ChangeStreamOperationTests : OperationTestBase
3939 {
4040 [ 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 ( )
42126 {
43127 var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
44128 var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -50,17 +134,19 @@ public void constructor_should_initialize_instance()
50134 subject . BatchSize . Should ( ) . NotHaveValue ( ) ;
51135 subject . Collation . Should ( ) . BeNull ( ) ;
52136 subject . CollectionNamespace . Should ( ) . BeSameAs ( collectionNamespace ) ;
137+ subject . DatabaseNamespace . Should ( ) . BeNull ( ) ;
53138 subject . FullDocument . Should ( ) . Be ( ChangeStreamFullDocumentOption . Default ) ;
54139 subject . MaxAwaitTime . Should ( ) . NotHaveValue ( ) ;
55140 subject . MessageEncoderSettings . Should ( ) . BeSameAs ( messageEncoderSettings ) ;
56141 subject . Pipeline . Should ( ) . Equal ( pipeline ) ;
57142 subject . ReadConcern . Should ( ) . Be ( ReadConcern . Default ) ;
58143 subject . ResultSerializer . Should ( ) . BeSameAs ( resultSerializer ) ;
59144 subject . ResumeAfter . Should ( ) . BeNull ( ) ;
145+ subject . StartAtOperationTime . Should ( ) . BeNull ( ) ;
60146 }
61147
62148 [ Fact ]
63- public void constructor_should_throw_when_collectionNamespace_is_null ( )
149+ public void constructor_with_collection_should_throw_when_collectionNamespace_is_null ( )
64150 {
65151 CollectionNamespace collectionNamespace = null ;
66152 var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -75,7 +161,7 @@ public void constructor_should_throw_when_collectionNamespace_is_null()
75161 }
76162
77163 [ Fact ]
78- public void constructor_should_throw_when_pipeline_is_null ( )
164+ public void constructor_with_collection_should_throw_when_pipeline_is_null ( )
79165 {
80166 var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
81167 var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -90,7 +176,7 @@ public void constructor_should_throw_when_pipeline_is_null()
90176 }
91177
92178 [ Fact ]
93- public void constructor_should_throw_when_messageEncoderSettings_is_null ( )
179+ public void constructor_with_collection_should_throw_when_messageEncoderSettings_is_null ( )
94180 {
95181 var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
96182 var pipeline = new List < BsonDocument > { BsonDocument . Parse ( "{ $match : { operationType : \" insert\" } }" ) } ;
@@ -105,7 +191,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null()
105191 }
106192
107193 [ Fact ]
108- public void constructor_should_throw_when_resultSerializer_is_null ( )
194+ public void constructor_with_collection_should_throw_when_resultSerializer_is_null ( )
109195 {
110196 var collectionNamespace = new CollectionNamespace ( new DatabaseNamespace ( "foo" ) , "bar" ) ;
111197 List < BsonDocument > pipeline = null ;
@@ -259,6 +345,20 @@ public void ResumeAfter_get_and_set_should_work(
259345 result . Should ( ) . Be ( value ) ;
260346 }
261347
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+
262362 [ SkippableTheory ]
263363 [ ParameterAttributeData ]
264364 public void Execute_should_return_expected_results_for_drop_collection (
0 commit comments