Print Page | Close Window

how to return fake data on a repository method

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3507
Printed Date: 29-Apr-2025 at 7:28pm


Topic: how to return fake data on a repository method
Posted By: pponzano
Subject: how to return fake data on a repository method
Date 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



Replies:
Posted By: mgood
Date 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>>();
}



Print Page | Close Window