@@ -159,6 +159,96 @@ public void CoerceOutputValue_Valid(byte precision, DateTimeOffset dateTime, str
159159 resultValue . MatchInlineSnapshot ( $ "\" { result } \" ") ;
160160 }
161161
162+ [ Theory ]
163+ [ InlineData ( DateTimeOptions . DefaultOutputPrecision , "2023-12-24T15:30:00.1234567Z" ) ]
164+ [ InlineData ( 3 , "2023-12-24T15:30:00.123Z" ) ]
165+ public void CoerceOutputValue_AlwaysOutputFractionalSeconds_Pads ( byte precision , string expected )
166+ {
167+ // arrange
168+ var type = new DateTimeType (
169+ new DateTimeOptions
170+ {
171+ OutputPrecision = precision ,
172+ AlwaysOutputFractionalSeconds = true
173+ } ) ;
174+ var dateTime = new DateTimeOffset ( 2023 , 12 , 24 , 15 , 30 , 0 , 123 , 456 , TimeSpan . Zero ) . AddTicks ( 7 ) ;
175+
176+ // act
177+ var operation = CommonTestExtensions . CreateOperation ( ) ;
178+ var resultDocument = new ResultDocument ( operation , 0 ) ;
179+ var resultValue = resultDocument . Data . GetProperty ( "first" ) ;
180+ type . CoerceOutputValue ( dateTime , resultValue ) ;
181+
182+ // assert
183+ resultValue . MatchInlineSnapshot ( $ "\" { expected } \" ") ;
184+ }
185+
186+ [ Fact ]
187+ public void CoerceOutputValue_AlwaysOutputFractionalSeconds_EmitsZerosForWholeSecond ( )
188+ {
189+ // arrange
190+ var type = new DateTimeType (
191+ new DateTimeOptions
192+ {
193+ OutputPrecision = 3 ,
194+ AlwaysOutputFractionalSeconds = true
195+ } ) ;
196+ var dateTime = new DateTimeOffset ( 2023 , 12 , 24 , 15 , 30 , 0 , TimeSpan . Zero ) ;
197+
198+ // act
199+ var operation = CommonTestExtensions . CreateOperation ( ) ;
200+ var resultDocument = new ResultDocument ( operation , 0 ) ;
201+ var resultValue = resultDocument . Data . GetProperty ( "first" ) ;
202+ type . CoerceOutputValue ( dateTime , resultValue ) ;
203+
204+ // assert
205+ resultValue . MatchInlineSnapshot ( "\" 2023-12-24T15:30:00.000Z\" " ) ;
206+ }
207+
208+ [ Fact ]
209+ public void CoerceOutputValue_AlwaysOutputFractionalSeconds_NoOpWhenPrecisionZero ( )
210+ {
211+ // arrange
212+ var type = new DateTimeType (
213+ new DateTimeOptions
214+ {
215+ OutputPrecision = 0 ,
216+ AlwaysOutputFractionalSeconds = true
217+ } ) ;
218+ var dateTime = new DateTimeOffset ( 2023 , 12 , 24 , 15 , 30 , 0 , 123 , TimeSpan . Zero ) ;
219+
220+ // act
221+ var operation = CommonTestExtensions . CreateOperation ( ) ;
222+ var resultDocument = new ResultDocument ( operation , 0 ) ;
223+ var resultValue = resultDocument . Data . GetProperty ( "first" ) ;
224+ type . CoerceOutputValue ( dateTime , resultValue ) ;
225+
226+ // assert
227+ resultValue . MatchInlineSnapshot ( "\" 2023-12-24T15:30:00Z\" " ) ;
228+ }
229+
230+ [ Fact ]
231+ public void CoerceOutputValue_AlwaysOutputFractionalSeconds_LocalOffset ( )
232+ {
233+ // arrange
234+ var type = new DateTimeType (
235+ new DateTimeOptions
236+ {
237+ OutputPrecision = 3 ,
238+ AlwaysOutputFractionalSeconds = true
239+ } ) ;
240+ var dateTime = new DateTimeOffset ( 2023 , 12 , 24 , 15 , 30 , 0 , TimeSpan . FromHours ( 4 ) ) ;
241+
242+ // act
243+ var operation = CommonTestExtensions . CreateOperation ( ) ;
244+ var resultDocument = new ResultDocument ( operation , 0 ) ;
245+ var resultValue = resultDocument . Data . GetProperty ( "first" ) ;
246+ type . CoerceOutputValue ( dateTime , resultValue ) ;
247+
248+ // assert
249+ resultValue . MatchInlineSnapshot ( "\" 2023-12-24T15:30:00.000+04:00\" " ) ;
250+ }
251+
162252 [ Fact ]
163253 public void CoerceOutputValue_Utc_DateTimeOffset ( )
164254 {
0 commit comments