Trying to run an NUnit test to store and retrieve an item and ensure that the item retrieved is the same as the item stored.
Getting an error that there is no overload for method RetrieveBook that takes 0 arguments.
I have updated all my code to put the books in a list, this is when the issues started. Not sure what I am supposed to be calling with RetrieveBook though.
Code:
public void TestStoreAndRetrieve()
{
Factory factory = Factory.GetInstance();
IBookService bookSvc = (IBookService)factory.GetService(typeof(IBookService).Name);
Book book1 = new Book("9781426829758", "Stock", "Dark Rival", "Masters of Time", "Brenda Joyce", "Time Travel");
bookSvc.StoreBook(book1);
Book book2 = bookSvc.RetrieveBook();
Assert.AreEqual(book1, book2);
I have updated all my code to put the books in a list, this is when the issues started. Not sure what I am supposed to be calling with RetrieveBook though.
Code:
public interface IBookService : IService
{
void StoreBook(Book bookx);
void StoreBookList(Book[] bookx);
void RetrieveBook(Book bookx);
Book[] RetrieveBookList(int maxcount);
//Book RetrieveBook();
}
Code:
public void RetrieveBook(Book bookx)
{
FileStream loadStream = new FileStream("Book.bin", FileMode.Open, FileAccess.Read);
IFormatter formatter = new BinaryFormatter();
IList<Book> listBooks = formatter.Deserialize(loadStream) as IList<Book>;
//Book bookX = formatter.Deserialize(loadStream) as Book;
loadStream.Close();
//return bookX;
}
Comment