New Posts New Posts RSS Feed: how to return fake data on a repository method
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

how to return fake data on a repository method

 Post Reply Post Reply
Author
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Topic: how to return fake data on a repository method
    Posted: 26-Jun-2012 at 2:10am
Hello,
I've got a simple stupid question..... if I want to test a call to the db and I want to create on the fly fake data how can I do this when I use an OperationResult<T> method?

If I'm in a classical application I can do

public IEnumerable<Item> GetItems()
{
    var List<Item> lst = new List<Item>();

[some iteration]

return lst
}

when I'm with

  public OperationResult<IEnumerable<Item>> LoadItemss(Action<IEnumerable> onSuccess = null, Action<Exception> onFail = null)
        {
            //how do I return fake items here?

            return op.OnComplete(onSuccess, onFail).AsOperationResult<Item>();
        }

Thanks
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 26-Jun-2012 at 8:49am
I take it you don't want to use the fake backing store. That would be one way. It looks like you simply want to fake a repository on the client. You use a coroutine to do what you want.
 

public IEnumerable<INotifyCompleted> GetItems()
{
var List<Item> lst = new List<Item>();

[some iteration]

yield return Coroutine.Return(lst);
}
 
  public OperationResult<IEnumerable<Item>> LoadItemss(Action<IEnumerable> onSuccess = null, Action<Exception> onFail = null)
{
            return Coroutine.Start(GetItems).OnComplete(onSuccess, onFail).AsOperationResult<IEnumerable<Item>>();
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down