Click here to Skip to main content
15,900,973 members
Home / Discussions / C#
   

C#

 
GeneralRe: determine OS is windows 2003 or 2008 Pin
Amr M. K.22-May-08 20:26
Amr M. K.22-May-08 20:26 
GeneralRe: determine OS is windows 2003 or 2008 Pin
Reelix22-May-08 20:45
Reelix22-May-08 20:45 
QuestionIHTML element question... Pin
sagedread22-May-08 14:09
sagedread22-May-08 14:09 
QuestionC# Convertion Pin
Illegal Operation22-May-08 13:24
Illegal Operation22-May-08 13:24 
AnswerRe: C# Convertion Pin
Anthony Mushrow22-May-08 13:35
professionalAnthony Mushrow22-May-08 13:35 
AnswerRe: C# Convertion Pin
Christian Graus22-May-08 13:40
protectorChristian Graus22-May-08 13:40 
AnswerRe: C# Convertion Pin
Nouman Bhatti22-May-08 20:16
Nouman Bhatti22-May-08 20:16 
QuestionMocks... I don't get it. Pin
martin_hughes22-May-08 11:25
martin_hughes22-May-08 11:25 
On Pete's recommendation I'm having a play with MoQ. Just for S&G I have an IPerson which defines FirstName, LastName, and DateOfBirth and a Suspect class which implements IPerson.

Now, I want to (for arguments sake) "test" something on this class, namely that if I set FirstName to something, it returns what what it was setup with:

var mockery = new Mock[Suspect]();
mockery.Expect(x => x.FirstName).Returns("Martin");
Assert.AreEqual("Martin", mockery.Object.FirstName);


The test fails because mockery.Object.FirstName returns null.

However this test (based on the interface) passes:

var mockery = new Mock[IPerson]();
mockery.Expect(x => x.FirstName).Returns("Martin");
Assert.AreEqual("Martin", mockery.Object.FirstName);


Why does this pass? What am I missing? Why can't I mock concrete classes, rather than interfaces, especially if a class doesn't implement an interface?

*Note - Ignore the square brackets, they're supposed to be < and > symbols but they ain't working for me!
AnswerRe: Mocks... I don't get it. Pin
#realJSOP22-May-08 11:33
professional#realJSOP22-May-08 11:33 
GeneralRe: Mocks... I don't get it. Pin
martin_hughes22-May-08 11:45
martin_hughes22-May-08 11:45 
AnswerRe: Mocks... I don't get it. Pin
Spacix One22-May-08 11:41
Spacix One22-May-08 11:41 
GeneralRe: Mocks... I don't get it. Pin
Pete O'Hanlon22-May-08 11:47
mvePete O'Hanlon22-May-08 11:47 
GeneralRe: Mocks... I don't get it. Pin
Spacix One22-May-08 11:57
Spacix One22-May-08 11:57 
AnswerRe: Mocks... I don't get it. Pin
Pete O'Hanlon22-May-08 11:43
mvePete O'Hanlon22-May-08 11:43 
GeneralRe: Mocks... I don't get it. Pin
martin_hughes22-May-08 11:59
martin_hughes22-May-08 11:59 
GeneralRe: Mocks... I don't get it. Pin
Pete O'Hanlon22-May-08 22:31
mvePete O'Hanlon22-May-08 22:31 
GeneralRe: Mocks... I don't get it. Pin
martin_hughes22-May-08 23:23
martin_hughes22-May-08 23:23 
AnswerOT Pin
Vikram A Punathambekar22-May-08 19:13
Vikram A Punathambekar22-May-08 19:13 
AnswerRe: Mocks... I don't get it. [modified] Pin
Roger Alsing23-May-08 0:36
Roger Alsing23-May-08 0:36 
GeneralRe: Mocks... I don't get it. Pin
martin_hughes23-May-08 0:48
martin_hughes23-May-08 0:48 
Questionhow to add blank line Pin
netJP12L22-May-08 11:24
netJP12L22-May-08 11:24 
AnswerRe: how to add blank line Pin
#realJSOP22-May-08 11:34
professional#realJSOP22-May-08 11:34 
AnswerRe: how to add blank line Pin
Anthony Mushrow22-May-08 11:37
professionalAnthony Mushrow22-May-08 11:37 
AnswerRe: how to add blank line Pin
Pete O'Hanlon22-May-08 11:38
mvePete O'Hanlon22-May-08 11:38 
GeneralRe: how to add blank line Pin
netJP12L22-May-08 11:59
netJP12L22-May-08 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.