What is the best way to test Silverlight 5 Class libraries? - silverlight

important requirement: support running the tests in the Nightly Build of the TFS.
p.s -
Those I know are NUnit, and Silverlight testing framework. don't know which of them is suitable or preferred for my needs.

NUNit will work for class libraries. Just create objects, call functions and use Assert functions to test if actual = expected.

What is contained in the Silverlight libraries? One limiting solution is to convert them to Portable Class Libraries. These could then be referenced from ordinary Test projects.

Related

NUnit project structure

I have some question regarding the NUnit test project and very new with NUnit.
For every wpf project there should be a test project or a single test project for a solution?
The test project will be class library project?
Thanks in advance. I am waiting for your quick response
Your first question is addressed here already: Which is better? Unit-test project per solution or per project? In a nutshell, there's no hard and fast rule, just be consistent and when possible try to mimic how you expect your libraries to be used.
For your second question, yes, it should be a library. It won't have anything other unit tests -- which are just classes with methods -- so there's no reason to make it an application or any other type of project.

Automatic C/C++ mock generation for XCTest - CMock/OCMock?

I want to develop using C & C++ using XCode 5. I particularly like the integration of XCTest and Xcode and the CI capability that you get by using OSX Server. I want to have a mocking framework, and ideally one where the mocks are automatically generated, as this seems most likely to ensure that the mocks follow a standard format (and themselves are not going to have errors).
Q1. I can't see how OCMock can work for mocking C & C++: is this possible?
Q2. CMock seems to be great, but it relies on Unity. Is it possible to integrate CMock into XCTest?
Q3. Does anyone have any other suggestions please?
Q1. OCMock can only mock methods on Objective-C classes, objects, and protocols.
Q2. What is Unity? (And I'm asking this as the maintainer of OCMock...)
Q3. There are several options for C and C++, I don't have much experience, never mind a strong recommendation.

Using IOC container in silverlight to dynamically load assembly. Is this possible?

I have two silverlight assemblies.
In assembly 1 I have implemented an interface ISnProvider.
In assembly 2 I have a concrete class which implements the ISnProvider.
I plan on having more assemblies which will contain different implementations of ISnProvider.
Assembly 1 has no reference to assembly 2.
When my silverlight app starts up, I want to resolve the ISnProvider interface using an IOC container. Ideally I won't have to recompile my app to use different providers. I don't want to hardcode 'assembly2.dll' in my assembly 1.
Which IOC container will allow me to dynamically load these assemblies using silverlight?
Thank you!
santiago
You might want to take a look at the Managed Extensibility Framework (MEF) from Microsoft. That will certainly support your scenario (example here) although it does unfortunately mean you need to use attributes (e.g. [Import] / [Export]) at various places in your code.
Autofac is available in a Silverlight version and I would certainly recommend it for general IOC usage with Silverlight but I've never tried to get it to dynamically load an assembly without a direct reference and I'm not sure if it will support that in Silverlight (I'd love to hear if anyone has accomplished this with Autofac)
You could also use a semi-manual approach - here's an example of loading an assembly dynamically in Silverlight without an IOC container, which may or may not be useful for you.

Unit testing "hybrid" WPF/Silverlight controls

I'm starting a new WPF/Silverlight custom control project and wanted to do unit testing on this one. However I'm a little confused about how to approach this.
This control would be based on the same codebase for both WPF and Silverlight with minor forking using #ifs and partial classes to tame the differences. I guess I could write unit tests for WPF part with NUnit, MSTest, xUnit, etc. and for the Silverlight part with Silverlight Unit Test Framework but this doesn't sound very elegant to me. I'd have to either ignore testing identical code on one of the platforms and test only differing parts (which is not very trustworthy) or rewrite tests for 2 frameworks (which is annoying). Is this the right way to go?
I'm wondering if there's some guidance, articles, tutorials out there on how to approach this task. Any pointers?
I am hardly an expert in WPF and Silverlight, but wouldn't it be possible to write the tests using the same techniques as the production code (#ifs and partial classes as you said)?
I tried to use xUnit first but it was kind of complicated to make same tests work in xUnit and SLUT (different attributes, syntax, etc.)
Then I did some basic experimenting with MSTest and from very simple test it looks like you can successfully use MSTest for the WPF part and same code with some #ifs, etc. and SLUT for the Silverlight part. So I'll try to go this route and see how it works in real-world situations.

xUnit testing framework for C

I'm developing a fairly simple C project for an embedded device. I'd like to employ xUnit testing. I've settled down with the Check framework (http://check.sourceforge.net/), but it seems it doesn't support function stubs. I remember using a very syntactically similar framework a few years ago that supported stubs, but i can't remember its name.
So, can anyone suggest an xUnit framework for C that supports stubs? A way to imitate stubs while using Check library would be OK, too.
Cgreen supports mock functions, is this what you want?
https://cgreen-devs.github.io/#_what_are_mock_functions

Resources