This is a user sandbox of Arcrowel. You can use it for testing or practicing edits. This is not the sandbox where you should draft your assigned article for a dashboard.wikiedu.org course. To find the right sandbox for your assignment, visit your Dashboard course page and follow the Sandbox Draft link for your assigned article in the My Articles section. |
A long time ago, it was a good day to test.
Checking one's work is a good thing to do.[1]
But the testing never really ends.
If someone wanted to write a test looking for a library that receives public funding, or by its head librarian, he or she might use code like the following:
Java
assertEqual(
l.getHeadLibrarian()
.getName().split(" ")[1]
, "Smith")
assertEqual(
l.getFunding().getType()
, "public")
Ruby
l.headLibrarian.name.split(/ +/).last.should == "Smith"
l.funding.type.should == "public"
To mock up an object that matches the search result, they would have to have mocking code like what follows:
Java
HeadLibrarian h = mock(HeadLibrarian.class);
when(h.getName()).thenReturn("Jane Smith");
Funding f = mock(Funding.class);
when(f.getType()).thenReturn("public");
Library l = mock(Library.class);
when(l.getHeadLibrarian()).thenReturn(h);
when(l.getFunding()).thenReturn(f);
Ruby
h = mock('HeadLibrarian', :name => 'Jane Smith')
f = mock('Funding', :type => 'public')
l = mock('Library', :HeadLibrarian => h, :Funding => f)
Notes
edit- ^ google.com