Enough to ensure that you are correctly getting the Webcast that has the most recent PublishDate, not simply the one that happens to have been most recently added to wherever the Webcasts are stored. Maybe make sure it works when there are no Webcasts stored, when there is one Webcast, and when there are multiple Webcasts.
Here's a question -- what if the PublishDate is in the future? Should it be returned? If not, that's another test.
What happens if two Webcasts have the same PublishDate? Which one is "the latest"? Whatever the answer, there's a scenario for another test.
It's a trick question. It takes as many tests as is necessary to drive out the design.
I'd probably start with something like:
public void GetLatestWebcastCallsGetLatestOfDAO();
since we'll have some sort of data access. I'd also likely have tests in place for equality and hashCode of the Webcast object itself (though it could be
abstracted away).
Then, for the DAO, I'd likely have tests in place to make sure that we were calling the data layer correctly, probably by using an in-memory DB. Then we'd need integration tests to make sure everything was working correctly.
The whole nullable DateTime seems interesting - but it also seems like it would be abstracted by the data access layer. If we store the webcasts in a file system, then we have at least the create or last modified date. If they are in the database, then we could use the max primary key, or filter out those records which don't have a publish date.
So, filtering out the test cases for Webcast itself, and the data access layer, then we'd need one - an interaction-based tests which verifies that GetLatestWebcast calls the appropriate DAL method.
It depends on what the GetLatest() method's dependencies are. You probably don't have to test the Webcast class unless there is actually code that you have written.. if it's just a bunch of properties, there is no need to test whether the .NET framework does its job.
It depends on the purpose of the class this method comes from. Is it the ultimate source for information on Webcasts, or is it just your local access point for it.
In other word, does this class hold a handle to a database connection or a RSS feed; or is it the database?
If it is the ultimate source, then there are probably a lot that should be done, but say which would require more intimate details of the class.
If it's local the local access point, then you are pretty much limited to range/reasonableness checks on the properties of the returned object. Anything beyond that, you aren't testing the method, your're testing the mocks.
Any attempts to answer this question that aren't phrased along the lines of "can you tell me more about the acceptance criteria" will be addressed by our human resources staff during your exit interview.
More information is needed. What are the rules surrounding the publishing of web casts? Can more than one webcast be published on the same date? If so, do you rank them by their Id? How is a null PublishDate handled - is it in the future or in the past?
> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
>
> * You can quote a list.
> * Etc.
Horizontal Rules
Three or more dashes or asterisks:
---
* * *
- - - -
Manual Line Breaks
End a line with two or more spaces:
Roses are red,
Violets are blue.
Fenced Code Blocks
Code blocks delimited by 3 or more backticks or tildas:
```
This is a preformatted
code block
```
Header IDs
Set the id of headings with {#<id>} at end of heading line:
## My Heading {#myheading}
Tables
Fruit |Color
---------|----------
Apples |Red
Pears |Green
Bananas |Yellow
Definition Lists
Term 1
: Definition 1
Term 2
: Definition 2
Footnotes
Body text with a footnote [^1]
[^1]: Footnote text here
Abbreviations
MDD <- will have title
*[MDD]: MarkdownDeep
FUTURE POSTS
No future posts left, oh my!
RECENT SERIES
Challenge
(75): 01 Jul 2024 - Efficient snapshotable state
Recording
(14): 19 Jun 2024 - Building a Database Engine in C# & .NET
Comments
None, good programmers write perfect code first time.
Enough to ensure that you are correctly getting the Webcast that has the most recent PublishDate, not simply the one that happens to have been most recently added to wherever the Webcasts are stored. Maybe make sure it works when there are no Webcasts stored, when there is one Webcast, and when there are multiple Webcasts.
Here's a question -- what if the PublishDate is in the future? Should it be returned? If not, that's another test.
What happens if two Webcasts have the same PublishDate? Which one is "the latest"? Whatever the answer, there's a scenario for another test.
@JacobM - Yet another case is what should GetLatest() do if (!PublishDate.HasValue)?
It's a trick question. It takes as many tests as is necessary to drive out the design.
I'd probably start with something like:
public void GetLatestWebcastCallsGetLatestOfDAO();
since we'll have some sort of data access. I'd also likely have tests in place for equality and hashCode of the Webcast object itself (though it could be abstracted away).
Then, for the DAO, I'd likely have tests in place to make sure that we were calling the data layer correctly, probably by using an in-memory DB. Then we'd need integration tests to make sure everything was working correctly.
The whole nullable DateTime seems interesting - but it also seems like it would be abstracted by the data access layer. If we store the webcasts in a file system, then we have at least the create or last modified date. If they are in the database, then we could use the max primary key, or filter out those records which don't have a publish date.
So, filtering out the test cases for Webcast itself, and the data access layer, then we'd need one - an interaction-based tests which verifies that GetLatestWebcast calls the appropriate DAL method.
It depends on what the GetLatest() method's dependencies are. You probably don't have to test the Webcast class unless there is actually code that you have written.. if it's just a bunch of properties, there is no need to test whether the .NET framework does its job.
7!
42; always 42.
It depends on the purpose of the class this method comes from. Is it the ultimate source for information on Webcasts, or is it just your local access point for it.
In other word, does this class hold a handle to a database connection or a RSS feed; or is it the database?
If it is the ultimate source, then there are probably a lot that should be done, but say which would require more intimate details of the class.
If it's local the local access point, then you are pretty much limited to range/reasonableness checks on the properties of the returned object. Anything beyond that, you aren't testing the method, your're testing the mocks.
You must not forget the case where there are 0 webcasts or where the colection is null.
Why PublishDate is nullable?
Any attempts to answer this question that aren't phrased along the lines of "can you tell me more about the acceptance criteria" will be addressed by our human resources staff during your exit interview.
I agree David, always 42!! ;)
Alex,
Because you may want to have a webcast that is not published.
Scott,
LOL
1, if you accept whitebox tests.
More information is needed. What are the rules surrounding the publishing of web casts? Can more than one webcast be published on the same date? If so, do you rank them by their Id? How is a null PublishDate handled - is it in the future or in the past?
Another vote for more information:
Does it throw exceptions? If so, what ones, and why?
Does it GetLatest() modify the state of the instance of the type it's contained in. If so, under what conditions?
Is a null a valid return value. If so, under what conditions will this occur?
...plus the other questions about more information.
What is the current datetime ... because the "Latest" may well depend on that too....
Scott got it :)
Comment preview