Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mock naming code & tests in Silverlight #83

Merged
merged 1 commit into from
Jan 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Source.Silverlight/Moq.Silverlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@
<Compile Include="..\Source\Proxy\IProxyFactory.cs">
<Link>Poxy\IProxyFactory.cs</Link>
</Compile>
<Compile Include="..\Source\Proxy\ProxyGenerationHelpers.cs">
<Link>Poxy\ProxyGenerationHelpers.cs</Link>
</Compile>
<Compile Include="..\Source\Range.cs">
<Link>Range.cs</Link>
</Compile>
Expand Down Expand Up @@ -414,4 +417,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
10 changes: 7 additions & 3 deletions Source/Mock.Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@
// http://www.opensource.org/licenses/bsd-license.php]

using System;
using System.CodeDom;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using Microsoft.CSharp;
using Moq.Language.Flow;
using Moq.Proxy;
using Moq.Language;
using Moq.Properties;
using System.Reflection;

#if !SILVERLIGHT
using System.CodeDom;
using Microsoft.CSharp;
#endif

namespace Moq
{
/// <include file='Mock.Generic.xdoc' path='docs/doc[@for="Mock{T}"]/*'/>
Expand Down Expand Up @@ -120,6 +122,7 @@ private string GenerateMockName()

var typeName = typeof (T).FullName;

#if !SILVERLIGHT
if (typeof (T).IsGenericType)
{
using (var provider = new CSharpCodeProvider())
Expand All @@ -128,6 +131,7 @@ private string GenerateMockName()
typeName = provider.GetTypeOutput(typeRef);
}
}
#endif

return "Mock<" + typeName + ":" + randomId + ">";
}
Expand Down
5 changes: 3 additions & 2 deletions UnitTests/MockFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using Xunit;
Expand Down Expand Up @@ -45,13 +44,15 @@ public void HasADefaultNameThatIncludesItsTypeAndThatItsAMock()
Assert.Contains("mock", mock.ToString().ToLower());
}

#if !SILVERLIGHT
[Fact]
public void HasADefaultNameThatIncludesItsGenericParameters()
{
var mock = new Mock<Dictionary<int, string>>();

Assert.Contains("System.Collections.Generic.Dictionary<int, string>", mock.ToString());
}
#endif

[Fact]
public void PassesItsNameOnToTheResultingMockObjectWhenMockingInterfaces()
Expand All @@ -64,7 +65,7 @@ public void PassesItsNameOnToTheResultingMockObjectWhenMockingInterfaces()
[Fact]
public void PassesItsNameOnToTheResultingMockObjectWhenMockingClasses()
{
var mock = new Mock<ArrayList>();
var mock = new Mock<Foo>();

Assert.Equal(mock.ToString() + ".Object", mock.Object.ToString());
}
Expand Down