Sorry for the bad title, I am not really sure what my issue is with as I dont understand it. I have a task that I have to complete where I need to get a unit test to pass (below).
[Test]
public void TheJarShouldContain30SweetsWhenCreated()
{
IJarOfSweetsCreator jarOfSweetsCreator = new JarOfSweetsCreator();
IJarOfSweets jarOfSweets = jarOfSweetsCreator.Create();
const int expectedNumberOfSweets = 30;
int numberOfSweets = jarOfSweets.Count;
Assert.AreEqual(expectedNumberOfSweets, numberOfSweets);
}
Although it is not much to go on, JarOfSweetsCreator has this code:
public class JarOfSweetsCreator : IJarOfSweetsCreator
{
public IJarOfSweets Create()
{
//throw new NotImplementedException();
}
}
and IJarOfSweets has this:
public interface IJarOfSweets : IReadOnlyCollection<ISweet>
{
void Shuffle ();
ISweet TakeSweetFromJar ();
}
So the idea is that I have to make the test pass from creating and counting 30 from IJarOfSweets and I cannot modify the test code. I dont understand how to create and count 30 instances of an interface if you can only have one but I know that sounds daft. I am assuming it has something to do with the IReadOnlyCollection<ISweet>
part of the IJarOfSweets
interface but I dont know how to use it. Is IJarOfSweets
used like a collection or would I create a collection within this interface? If it is a read only collection, how am I supposed to make 30 of them? If it really isn't possible to get the test to pass in this way then help with correcting it would also help.
Aucun commentaire:
Enregistrer un commentaire