• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: NSObject -poseAs:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSObject -poseAs:


  • Subject: RE: NSObject -poseAs:
  • From: Jeff Laing <email@hidden>
  • Date: Fri, 1 Jun 2007 10:43:50 +1000

> @implementation TestThingToTest
> - (void) testThingToTest
> {
> 	ThingToTest *thing = [[[ThingToTest alloc]init]autorelease];
> 	[[MockSingletonClass class] poseAs:[SingletonClass]];
> 	[thing methodToTest] ; // methodToTest uses the mock
> singleton ctor
> 	// Here's where it would be nice to unposeAs.
> }
> @end

It seems to me that this is not a well-formed test case.  If you "unpose",
are you expecting that a *new* singleton is going to be created, or that the
characteristics of the singleton will stop being your mock object and go
back to the original?

In any case, I suspect (though I'm not sure) that you could add a category
in your test case that overwrites the defaultSomething message in the real
singleton class, to return your subclass.

ie,
@interface SingletonClass(TestingOnly)
+ (id)defaultSomething;		// overwrite base message handler
@end

Now make defaultSomething return an instance of your MockSingletonClass
which has appropriate gates built in, that can enable/disable itself based
on a boolean you can twiddle via some private method.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Math operations for NSNumber
  • Next by Date: Re: "selected" table view column header
  • Previous by thread: Re: NSObject -poseAs:
  • Next by thread: "selected" table view column header
  • Index(es):
    • Date
    • Thread