Hi,
We are currently evaluating JustMock against Moq.
For a silverlight project I want to test the view generation. For this I have a viewmodel interface
And a UserControl as xamlx:
The test looks like this:
The test creates a View and waits for it to be loaded. Then the backgroundcolor is checked. It fails using JustMock (layoutRoot.Background is null), while it passes using Moq.
Looking at the Debug Output it tells that the Property BackgroundBrush could not be found on IViewModelProxy\+a45306a40f1f4947a9984002599ac998. Checking by hand the watch window gives me the proper type which only contains the mock framework properties. The same is true for a test checking DisplayName.
Is there anything I'm missing using JustMock?
We are currently evaluating JustMock against Moq.
For a silverlight project I want to test the view generation. For this I have a viewmodel interface
public interface IViewModel
{
string DisplayName { get; }
Brush BackgroundBrush { get; }
}
And a UserControl as xamlx:
<
UserControl
x:Class
=
"View"
[...]>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"{Binding Path=BackgroundBrush}"
>
<
Border
BorderBrush
=
"Black"
BorderThickness
=
"1"
>
<
TextBlock
Text
=
"{Binding Path=DisplayName}"
/>
</
Border
>
</
Grid
>
</
UserControl
>
The test looks like this:
[TestMethod]
[Asynchronous]
public
void
BindingTest_BackgroundBrushIsSet()
{
var target =
new
View();
var datacontextMock = Mock.Create<IViewModel>();
var expectedBackground =
new
SolidColorBrush(Colors.Purple);
target.DataContext = datacontextMock;
Mock.Arrange(() => datacontextMock.BackgroundBrush).Returns(expectedBackground);
Mock.Arrange(() => datacontextMock.DisplayName).Returns(
string
.Empty);
AsyncWaitForFrameworkElementLoaded(target);
AssertCallback
(() =>
{
var layoutRoot = target.FindName<Grid>(
"LayoutRoot"
);
Assert.AreEqual(expectedBackground, layoutRoot.Background);
});
}
The test creates a View and waits for it to be loaded. Then the backgroundcolor is checked. It fails using JustMock (layoutRoot.Background is null), while it passes using Moq.
Looking at the Debug Output it tells that the Property BackgroundBrush could not be found on IViewModelProxy\+a45306a40f1f4947a9984002599ac998. Checking by hand the watch window gives me the proper type which only contains the mock framework properties. The same is true for a test checking DisplayName.
Is there anything I'm missing using JustMock?