|
From: Jim A. <JA...@th...> - 2004-08-06 14:11:12
|
Without trying to pass the buck, that looks like a problem with csUnit
rather than NMock. It's trying to get the CodeBase property of the
dynamic assembly created by NMock, which is not allowed. Can you file a
bug report with the csUnit developers and ask them to catch
NotSupportedException in their OnAssemblyLoaded handler?
(By the way, that should fail in .Net 1.1 as well).
Jim
Mei Xiu <mx...@ya...>
Sent by: nmo...@li...
05/08/2004 22:00
To
nmo...@li...
cc
Subject
[Nmock-general] (no subject)
Hi there,
I would like to use NMock with .net framework v2.0.
but having problem as showing in the callstack below.
Has anyone successfully used NMock on .net v2.0? any
suggestion is appreciated. Thanks!
Summary
Tests run: 1
Errors: 1
**************************************
**************************************
Detailed errors
Test Name: test1.HelloTest.testExpect
Error Reason: System.NotSupportedException: The
invoked member is not supported in a dynamic module.
at
System.Reflection.Emit.AssemblyBuilder.get_CodeBase()
at csUnit.Core.RemoteLoader.OnAssemblyLoaded(Object
sender, AssemblyLoadEventArgs args)
at System.AppDomain.OnAssemblyLoadEvent(Assembly
LoadedAssembly)
at
System.AppDomain.nCreateDynamicAssembly(AssemblyName
name, Evidence identity, StackCrawlMark& stackMark,
PermissionSet requiredPermissions, PermissionSet
optionalPermissions, PermissionSet refusedPermissions,
AssemblyBuilderAccess access)
at
System.AppDomain.InternalDefineDynamicAssembly(AssemblyName
name, AssemblyBuilderAccess access, String dir,
Evidence evidence, PermissionSet requiredPermissions,
PermissionSet optionalPermissions, PermissionSet
refusedPermissions, StackCrawlMark& stackMark)
at
System.AppDomain.DefineDynamicAssembly(AssemblyName
name, AssemblyBuilderAccess access)
at NMock.Dynamic.ClassGenerator.CreateTypeBuilder()
in
d:\nexus\nmock\nmocksource\1.01\nmock\nmock\dynamic\classgenerator.cs:line
54
at NMock.Dynamic.ClassGenerator.Generate() in
d:\nexus\nmock\nmocksource\1.01\nmock\nmock\dynamic\classgenerator.cs:line
41
at NMock.DynamicMock.get_MockInstance() in
d:\nexus\nmock\nmocksource\1.01\nmock\nmock\dynamicmock.cs:line
34
at test1.HelloTest.testExpect() in
d:\nexus\nmock\testproject\test1\test1\test1\program.cs:line
88
-----------------------
Failures: 0
**************************************
Here is my source file:
using System;
using System.Collections.Generic;
using System.Collections;
using NMock;
using System.Text;
using com.siebel.nexus.test;
namespace test1
{
public class HelloTest : NexusTestCase
//NexusTestCase is extended from csUnit
{
public HelloTest(String name) : base (name)
{
}
public void testExpect()
{
// mock the dependency
IMock person = new
DynamicMock(typeof(IPerson));
// setting up values
person.ExpectAndReturn("Name", "John Doe");
Hello hello = new
Hello((IPerson)person.MockInstance);
assertEquals("Hello John Doe", hello.Greet());
// Verify that Name property is only accessed
once
person.Verify();
}
}
public interface Iperson
{
string Name { get; }
}
public class Hello
{
IPerson person;
public Hello(IPerson person)
{
this.person = person;
}
public String Greet()
{
return "Hello " + person.Name;
}
}
}
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
Nmock-general mailing list
Nmo...@li...
https://lists.sourceforge.net/lists/listinfo/nmock-general
|