# Getting started with IronRuby and c# issues

**URL:** <https://www.ruby-forum.com/t/getting-started-with-ironruby-and-c-issues/183796>\
**Category:** IronRuby\
**Created:** [February 20, 2010, 11:16am UTC](https://www.ruby-forum.com/t/getting-started-with-ironruby-and-c-issues/183796 "2010-02-20T11:16:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jngo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e95f7d/32.png) [@jngo](https://www.ruby-forum.com/u/jngo)\
**Post date:** [February 20, 2010, 11:16am UTC](https://www.ruby-forum.com/t/getting-started-with-ironruby-and-c-issues/183796/1 "2010-02-20T11:16:58Z")

</div>

Hi IronRuby mailing list,

Inspired by a talk by Ben H. on testing c# with Ruby I thought I’d  
give it  
a go but  
I’m frustratingly stuck at the first hurdle. I’ve emailed Ben but as  
I’ve  
not had an immediate response I thought I’d open it to you good people.

Any way. I thought I’d start off simple and follow Dom Green’s blog.  
[domgreen.com/2010/02/07/pumping-iron-ruby-net-testing/](http://domgreen.com/2010/02/07/pumping-iron-ruby-net-testing/)

He’s set a class in c# with a simple property (here’s mine)

namespace IronRubyAndCSharp  
{  
public class Person  
{  
public string FirstName { get; set; }

```
    public Person(string name)
    {
        FirstName = name;
    }
}

```

}

and tested it like so

require “test/unit”  
require “…/IronRuby/bin/debug/IronRubyAndCSharp.dll”

class PersonTest \< Test::Unit::TestCase  
include IronRubyAndCSharp  
def test\_create\_person\_called\_john  
john = Person.new(“John”)  
assert\_not\_nil(john)  
assert\_equal(“John”,Person.FirstName)  
end  
end

RubyMine(RM) has no problem with the require of the dll but it does have  
a  
problem recognising the namespace “IronRubyAndCSharp”  
and the Person class (squiggly lines ahoy).

When I run the tests in RM I get

NoMethodError: undefined method `FirstName' for IronRubyAndCSharp::Person:Class C:/Users/John/Documents/IronRuby/Tests/Person_test.rb:14:in `test\_create\_person\_called\_john’  
:0:in `send' :0:in `each’  
C:/Program Files (x86)/IronRuby  
0.9.4.0/Lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in  
`run_suite' :0:in `each’  
C:\Program Files (x86)\JetBrains\RubyMine  
2.0.1\rb\testing\patch\testunit/test/unit/ui/testrunnermediator.rb:36:in  
`run_suite' testrunner.rb:213:in `start\_mediator’  
C:\Program Files (x86)\JetBrains\RubyMine  
2.0.1\rb\testing\patch\testunit/test/unit/ui/teamcity/testrunner.rb:191:in  
`start' testrunnerutilities.rb:28:in `run’  
C:/Program Files (x86)/IronRuby  
0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' C:/Program Files (x86)/IronRuby 0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:12:in `run’

Just in case RubyMine was at fault I dropped out to good old ir.exe

C:\Users\John\Documents\IronRuby\Tests\>ir Person\_test.rb --name  
test\_create\_pers  
on\_called\_john  
Loaded suite Person\_test  
Started  
E  
Finished in 0.041992 seconds.

1. Error:  
test\_create\_person\_called\_john(PersonTest):  
NoMethodError: undefined method `FirstName' for IronRubyAndCSharp::Person:Class Person_test.rb:14:in `test\_create\_person\_called\_john’  
:0:in `send' :0:in `each’  
:0:in `each' testrunner.rb:66:in `start\_mediator’  
testrunnerutilities.rb:28:in `run’

1 tests, 1 assertions, 0 failures, 1 errors

I’ve stuck my code up on github  
[GitHub - johnnonolan/IronRubyAndCSharp: Getting started with Ruby and CSharp](http://github.com/johnnonolan/IronRubyAndCSharp) if you feel that was  
inclined.

Any pointers, help or whatever much appreciated.

PlzSendMeTehCodez

John(no)

---

<div class="post-metadata">

**Author:** ![jngo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e95f7d/32.png) [@jngo](https://www.ruby-forum.com/u/jngo)\
**Post date:** [February 20, 2010, 11:29am UTC](https://www.ruby-forum.com/t/getting-started-with-ironruby-and-c-issues/183796/2 "2010-02-20T11:29:51Z")

</div>

ironruby will have ‘rubified’ the Person class’s FirstName method to  
first\_name and I think you mean to assert against the john instance of  
Person (rather than the Person class).

Otherwise it looks pretty close.

Try:

require “test/unit”  
require “../IronRuby/bin/debug/IronRubyAndCSharp.dll”

class PersonTest \< Test::Unit::TestCase  
include IronRubyAndCSharp  
def test\_create\_person\_called\_john  
john = Person.new(“John”)  
assert\_not\_nil(john)  
assert\_equal(“John”,john.first\_name)  
end  
end

On Sat, Feb 20, 2010 at 9:16 PM, John N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi IronRuby mailing list,  
> Inspired by a talk by Ben H. on testing c# with Ruby I thought I’d give  
> it  
> public string FirstName { get; set; }  
> include IronRubyAndCSharp  
> NoMethodError: undefined method `FirstName' for IronRubyAndCSharp::Person:Class C:/Users/John/Documents/IronRuby/Tests/Person_test.rb:14:in `test\_create\_person\_called\_john’  
> :0:in `send' :0:in `each’  
> C:/Program Files  
> (x86)/IronRuby  
> 0.9.4.0/Lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in  
> `run_suite' (x86)/IronRuby 0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:216:in `run’
> 
> 1. Error:  
> I’ve stuck my code up on  
> github [GitHub - johnnonolan/IronRubyAndCSharp: Getting started with Ruby and CSharp · GitHub](http://github.com/johnnonolan/IronRubyAndCSharp) if you feel that  
> was
