Skip to main content

RuntimeBinderException cannot resolver property in Unit Test in case of dynamic return.. Solved

This is an issue that i have face while doing tests for a dynamic return method, while it worked on the run, it did not work on the testing environment so it had to be a mocking return issue, i was returning a collection of anonymous types and it was, how ever  i have found the solution, to illustrate the issue here is what happened in samples.
A sample test would normally fail cause of exception runtime binder exception

 so the test simply check for a return of a function that returns a dynamic object and checks for its return, once run a run time binder exception  will be thrown in the Assert statement as the props cannot be resolved.
The issue here is with anonymous types if you use ExpandoObject instead it should work fine with no problem. So replace the anonymous type with an expand object, check below


Popular posts from this blog

(AsyncWebClient) Async Webclient for windows phone 8

Using windows phone web client is pretty common but the thing is you can not use it using Async -> Await mechanism so i used threading to create an async functionality for The Download string and upload string methods here is the code below // Comment public class AsyncWebClient { public Task DownloadString(Uri uri) { var task = new TaskCompletionSource(); try { var client = new WebClient(); client.DownloadStringCompleted += (s, e) => { task.SetResult(e.Result); }; client.DownloadStringAsync(uri); } catch (Exception ex) { task.SetException(ex); } return task.Task; } public Task UploadString(Uri uri, string content) { var task = new TaskCompletionSource(); try { var client…

Xamarin UI Tests – Deep dive Part 1

IntroAs the title may describe this is the first of the series of articles that will cover the UI Test of Xamarin in a deep dive, we will start simple and then dig deeper as we go. Since this is very well the first of the series, it will mostly cover up the architecture and the testing technique that Xamarin UI Tests uses.

The Technology
Xamarin UI Test is an automation testing framework similar to selenium, Watir, Watin (.net), Robot and Sikuli, if you have used BDD (Behavioral Driven Development) or a more advanced TDD (Test Driven Development) approach at least you must have come across one of these frameworks, and in that perspective comes Xamarin UI Testing as an automation framework designed specifically for Xamarin Automation testing, For starter Xamarin UI Tests was not build from scratch, instead it was built on top of another UI Automation testing framework that is targeting android and iOS sepecifically which is Calabash, I have to say that this choice was made wisely as of n…