Hello,
I am trying to use JustMock on a view-model in a silverlight application. The structure of the solution is basically as follows:
Solution
SilverlightApp.proj
- ViewModels
ViewModelX.cs
-Views
ViewX.xaml
SIlverligthApp.Tests.proj
ViewModelXFixture.cs
Both projects are Silverlight Class projects with Silverlight 5. The test project is using NUnitLite 1.0 libraries (also tried it with NUnit3.0) and has a reference to Telerik.JustMock.Silverlight.dll. I have a license for the commercial version but have not enabled the profiler. A sample unit test is below:
And this is what I tried testing:
But this is the error I get:
Tests1.Class1Fixture.Len_Returns_Length:
System.TypeInitializationException : The type initializer for 'Telerik.JustMock.Mock' threw an exception.
----> System.InvalidOperationException : Telerik.JustMock.Silverlight should only be used inside the Silverlight runtime. For all other runtimes reference Telerik.JustMock instead.
But since the test project is a SilverLight class library, I cannot add a reference to Telerik.JustMock.dll.
I'm sure I'm missing something but just can recognize it at the moment. Any advice would be much appreciated.
Thanks,
Mike
I am trying to use JustMock on a view-model in a silverlight application. The structure of the solution is basically as follows:
Solution
SilverlightApp.proj
- ViewModels
ViewModelX.cs
-Views
ViewX.xaml
SIlverligthApp.Tests.proj
ViewModelXFixture.cs
Both projects are Silverlight Class projects with Silverlight 5. The test project is using NUnitLite 1.0 libraries (also tried it with NUnit3.0) and has a reference to Telerik.JustMock.Silverlight.dll. I have a license for the commercial version but have not enabled the profiler. A sample unit test is below:
[TestFixture]public class Class1Fixture{ [Test] public void Len_Returns_Length() { //Arrange var mockDummy = Mock.Create<IDummy>(); var x = new Class1(mockDummy); //Act var result = x.Len("test"); //Assert Assert.AreEqual(4, result); }}And this is what I tried testing:
public interface IDummy{ }public class Class1{ public Class1(IDummy dummy) { } public int Len(string input) { if (string.IsNullOrWhiteSpace(input)) return 0; return input.Length; }}But this is the error I get:
Tests1.Class1Fixture.Len_Returns_Length:
System.TypeInitializationException : The type initializer for 'Telerik.JustMock.Mock' threw an exception.
----> System.InvalidOperationException : Telerik.JustMock.Silverlight should only be used inside the Silverlight runtime. For all other runtimes reference Telerik.JustMock instead.
But since the test project is a SilverLight class library, I cannot add a reference to Telerik.JustMock.dll.
I'm sure I'm missing something but just can recognize it at the moment. Any advice would be much appreciated.
Thanks,
Mike