I'm using RIA Services authentication in a Silverlight app and it works great. Now I want to add unit tests using Moq framework: http://code.google.com/p/moq/
The problem I'm having is that I can't simulate none of the methods exposed by WebContext.Current.Authentication, since I can't return custom values for the mocked methods. For example, I can't simulate a successful login since I can't set a value for LoadUserOperation.IsComplete because that property doesn't have a public setter. The same happens with all the returned structures: they are readonly!
Is there a way I can simulate the authentication operations and therefore test the login in my app?
Thanks in advance.
I show how to mock authentication in this post.
Thanks for you help.
I found a solution after refactoring the code a little bit and adding proper interfaces and wrappers for the RIA services sealed classes. This guy shows how.
Related
I have a custom WebSockets server that triggers route changes in a AngularJS client. I would like to carry out e2e integration tests using protractor. As the route change events are every 30 seconds and involve multiuser interactions, it seems like creating a mock of the service is the best approach. Is there a recommended way of doing this in protractor?
I am not sure if this is exactly what you are looking for, but you can define mock services in Protractor and then upload them to the browser using Protractors browser.addMockModule function. The uploaded module will replace the real one that the application would normally use. See the following blog post for more details.
http://eitanp461.blogspot.com/2014/01/advanced-protractor-features.html
I recently had a similar problem and solved it using addMockModule as stated above. I wrote a post about it describing my solution.
http://www.functionalimperative.com/2015/04/22/protractor-socket-mocks.html
I found organizing my code a certain way helped when mocking the socket modules.
I am developing an AngularJS/Web Api application, is there any way that we can write any Page validations in C# code and can be called from AngularJS as a service call?
i.e. the C# code is converted to JSON object where the angularJS service read the JSON object to enable/disable other controls? With this approach i can keep all my validation logic in one centralised place.
I don't want to write the same validation logic in the Angular script.
Please suggest.
Thanks
If I understand you correctly, you want to have only server-side validation. And at the same time you want your validation to happen asynchronously at server. And for end-user it would seem like a client-side validation.
Whether you are using Web API or Spring java, it is possible. There is a framework that can greatly simplify it. Just download example and see how it works:
https://upida4net.codeplex.com
By the way, you can take a look at working example here: http://upida.cloudapp.net:8080/org.upida.example.angular/
I promise, you will be surprised with amount of code there.
I am currently developing a WCF service in a windows form application. There would be a simple GUI screen with 2 buttons, "Start" and "Stop". Whenever I attempt to start the service, the UI of the application would temporary hangs until it loads finish. Is it possible to add a loading effect to it? And how can I do that.
Still pretty new in this area. Would welcome any comments!
Is there any good tutorials out there that teaches how can I enhance this issue?
I have read the MSDN blog tutorial from Rick Rainey Making asynchronous service calls from a WinForm client but it is not really that of a good tutorial.
Just to clarify, my WCF service is a publish subscribe framework and I think I do not need to be able to call the operations asynchronously. All I want to know is how do I initiate the connection asynchronously.
Is it possible to add a loading effect to it? And how can I do that.
For this you can use duplex service contract.
Also, since your application is a subscription application you might want to look into pushing data to your application from the WCF service. Here's a nice example and although it's for Silverlight I think it might be useful to you:
http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx
I'm building a silverlight LOB application which uses both RIA services and a vanilla .ASMX service..
The data is wired up using entity framework..
I have 1 entity which i recently added a 1 to many relationship to a collection of a new type of object..
Using RIA services i can get to that in my silverlight application fine by saying:
instanceOfEntity.NewEntities
However in the vanilla service which is using the exact same object context class even after updating, deleting and recreating the service reference in the silverlight application.. the property is still not being exposed..
Someone Plleeaeeeeease tell my how i can get this dang thing to show up via this service!
Thanks
Daniel
Ended up switching to a WCF service instead..
Seems to work fine,
Not sure if this is a limitation in vanilla ASMX services?
I was using a simple WCF service with silverlight but I wanted to validate data with annotations and I didn't want to write a whole new layer in silverlight project. So I decided to switch to using a DomainService, created through generating code in the silverlight project.
Now comes the trouble. I have a parent class and about 10 derived classes. Through WCF, I was able to just use the base class. Now I am trying to use a DomainService with the base class decorated with the KnownType attribute. The problem is now those attributes get replicated in silverlight client and a compilation error is thrown. Anybody know how to use DomainService with inheritance? I want to deliver only the information from the base class.
I don't completely follow what your problem is, but this is a great tutorial on how to use Domain Services in Silverlight, and the example includes an abstract base class for all entities, similar to what I think you're doing.