Skip to content

Commit c3339bd

Browse files
committed
Test - Add JS Callback test that uses ExpandoObject (SerializeV8SimpleObject now supports Expando)
Follow up to #4959
1 parent 0a105f6 commit c3339bd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

CefSharp.Test/Javascript/JavascriptCallbackTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System;
6+
using System.Dynamic;
67
using System.Globalization;
78
using System.Threading.Tasks;
89
using Xunit;
@@ -207,5 +208,30 @@ public async Task ShouldEchoDateTimeNow()
207208

208209
output.WriteLine("Expected {0} : Actual {1}", expectedDateTime, actualDateTime);
209210
}
211+
212+
[Fact]
213+
public async Task ShouldWorkWithExpandoObject()
214+
{
215+
AssertInitialLoadComplete();
216+
217+
var expectedDateTime = DateTime.Now;
218+
219+
dynamic request = new ExpandoObject();
220+
request.dateTime = expectedDateTime;
221+
222+
var javascriptResponse = await Browser.EvaluateScriptAsync("(function(p) { return p; })");
223+
Assert.True(javascriptResponse.Success);
224+
225+
var callback = (IJavascriptCallback)javascriptResponse.Result;
226+
227+
var callbackResponse = await callback.ExecuteAsync(request);
228+
229+
dynamic response = callbackResponse.Result;
230+
var actualDateTime = (DateTime)response.dateTime;
231+
232+
Assert.Equal(expectedDateTime, actualDateTime, TimeSpan.FromMilliseconds(10));
233+
234+
output.WriteLine("Expected {0} : Actual {1}", expectedDateTime, actualDateTime);
235+
}
210236
}
211237
}

0 commit comments

Comments
 (0)