Sean
unread,Feb 3, 2009, 1:07:50 PM2/3/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino.Mocks, dmorg...@cortex.net, sfel...@cortex.net
Hi,
We run into an issue with the following code. If Line A and B are
switched, it works as expected, and the stubbed property is returning
the value it was given. If the original code is left (first Line A,
then Line B), the stubbed property is returning the default value and
not what was given to it during context establishment. Is this a bug
or something we are missing?
Thank you
Sean
-------------------------Code-------------------------
namespace QTUS.Server.Task
{
[Concern(typeof (GetVersionsTask))]
public abstract class GetVersionsTask_Specs :
ContextSpecification<IGetVersionsTask>
{
protected override void establish_context()
{
system_under_test = create_system_under_test();
}
protected override IGetVersionsTask create_system_under_test()
{
return new GetVersionsTask();
}
}
public class When_GetVersionsTask_is_asked_to_GetOutputXML :
GetVersionsTask_Specs
{
private QuikTikitUser quikTikitUser;
private Application application;
private const bool isActive = true;
private readonly ReadOnlyCollection<string>
userErrorCollection = new ReadOnlyCollection<string>(new List<string>
{"user error"});
private readonly ReadOnlyCollection<string> appErrorCollection
= new ReadOnlyCollection<string>(new List<string>{"app error"});
private string result;
private const string dataVersion = "1";
private const string appVersion = "1.1.1.1";
protected override void establish_context()
{
quikTikitUser = dependency<QuikTikitUser>();
application = dependency<Application>();
quikTikitUser.setup_result(x => x.GetErrors()).Return
(userErrorCollection);
quikTikitUser.IsActive =
isActive; //
<--- ISSUE (Line A)
quikTikitUser.setup_result(x => x.GetDataVersion()).Return
(dataVersion); // (Line B)
application.setup_result(x => x.GetErrors())
.Return(appErrorCollection);
application.Version = appVersion;
base.establish_context();
}
protected override void because()
{
result = system_under_test.CreateXMLOutput(quikTikitUser,
application);
}
[Observation]
public void
Should_ask_the_user_and_the_application_for_any_errors()
{
quikTikitUser.was_told_to(x => x.GetErrors());
application.was_told_to(x => x.GetErrors());
}
[Observation]
public void Should_ask_the_user_for_its_dataversion()
{
quikTikitUser.was_told_to(x => x.GetDataVersion());
}
private const string outputXML =
@"<reply>
<error>{0}</error>
<user>
<active>{1}</active>
</user>
<app>
<version>{2}</version>
</app>
<data>
<version>{3}</version>
</data>
</reply>";
[Observation]
public void Should_create_valid_xml()
{
var validXML = string.Format(outputXML, "user error - app
error", isActive, appVersion, dataVersion);
result.should_be_equal_to(validXML);
}
}
}