I have some integrationtests that is using S3Server as mock.
The setup is that I have a service that wraps calls to the AWSSDK.S3 api. I then write tests, where the AWSSDK.S3 api connects to the S3Server mock.
I get a System.FormatException when running the tests locally as my windows regional settings is set to Danish.
System.FormatException
The string 'man, 29 jan. 2024 13:48:27 GMT' was not recognized as a valid DateTime. There is an unknown word starting at index '0'.
at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Amazon.S3.Model.Internal.MarshallTransformations.S3Transforms.ToDateTime(String value)
at Amazon.S3.Model.Internal.MarshallTransformations.GetObjectResponseUnmarshaller.UnmarshallResult(XmlUnmarshallerContext context, GetObjectResponse response)
at Amazon.S3.Model.Internal.MarshallTransformations.GetObjectResponseUnmarshaller.Unmarshall(XmlUnmarshallerContext context)
at Amazon.Runtime.Internal.Transform.XmlResponseUnmarshaller.Unmarshall(UnmarshallerContext input)
at Amazon.S3.Model.Internal.MarshallTransformations.S3ReponseUnmarshaller.Unmarshall(UnmarshallerContext input)
at Amazon.Runtime.Internal.Transform.ResponseUnmarshaller.UnmarshallResponse(UnmarshallerContext context)
at Amazon.Runtime.Internal.Unmarshaller.UnmarshallResponse(UnmarshallerContext context, IRequestContext requestContext)
at Amazon.Runtime.Internal.Unmarshaller.UnmarshallAsync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.S3Express.S3ExpressPreSigner.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
at LetDialog.Infrastructure.Common.S3StorageClient.GetFileAsync(Guid id, CancellationToken cancellationToken) in C:\Users\mema\source\letdialog\source\Infrastructure\Common\S3StorageClient.cs:line 32
at LetDialog.Tests.IntegrationTests.Infrastructure.S3StorageClientTests.Storageclient_can_retrieve_saved_file_using_s3() in C:\Users\mema\source\letdialog\source\Tests.IntegrationTests\Infrastructure\S3StorageClientTests.cs:line 20
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_0.<<InvokeTestMethodAsync>b__1>d.MoveNext() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs:line 285
--- End of stack trace from previous location ---
at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in /_/src/xunit.execution/Sdk/Frameworks/ExecutionTimer.cs:line 48
at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90
It works fine, when the regional settings is set to english.
I believe this might be fixed by adding an IFormatProvider, where ToString is called.