public void Test11() { var list = new List <string>() { "B2", "B6", "B7" }; var readers = new List <Reader>() { CreateReader("R1", new List <string>() { "B1", "B2", "B3" }), CreateReader("R2", new List <string>() { "B3", "B1", "B5" }), CreateReader("R3", list) }; database = GetDatabase(readers); var service = new ReaderController(database, _logger); var result = service.GetReaderBooks("R3"); Assert.AreEqual(200, result.StatusCode); var output = (List <string>)result.Value; Assert.AreEqual(list.Count, output.Count); for (int i = 0; i < output.Count; i++) { Assert.AreEqual(list[i], output[i]); } }
public void Test3() { var readers = new List <Reader>() { CreateReader("R1", new List <string>() { "B1", "B2", "B3" }), CreateReader("R2", new List <string>() { "B3", "B1", "B5" }), CreateReader("R3", new List <string>() { "B2", "B6", "B7" }) }; var readersOutput = new List <ReaderOutput>() { new ReaderOutput() { Nickname = "R1", Books = new List <string>() { "B1", "B2", "B3" } }, new ReaderOutput() { Nickname = "R2", Books = new List <string>() { "B3", "B1", "B5" } }, new ReaderOutput() { Nickname = "R3", Books = new List <string>() { "B2", "B6", "B7" } } }; database = GetDatabase(readers); var service = new ReaderController(database, _logger); var result = service.Get(); Assert.AreEqual(200, result.StatusCode); var output = (List <ReaderOutput>)result.Value; Assert.AreEqual(readersOutput.Count, output.Count); for (int i = 0; i < output.Count; i++) { Assert.AreEqual(true, OutputEqual(readersOutput[i], output[i])); } }
private void ReadBook() { switch (_selectedBook.FileType) { case ".pdf": _readersContext = new ReadersContext(new PDFReader()); _readersContext.Read(_selectedBook.Path); break; case ".djvu": _readersContext = new ReadersContext(new DJVuReader()); _readersContext.Read(_selectedBook.Path); break; } }
public void Test8() { var readers = new List <Reader>() { CreateReader("R1", new List <string>() { "B1", "B2", "B3" }), CreateReader("R2", new List <string>() { "B3", "B1", "B5" }), CreateReader("R3", new List <string>() { "B2", "B6", "B7" }) }; var readersOutput = new List <Reader>() { CreateReader("R1", new List <string>() { "B1", "B2", "B3" }), CreateReader("R2", new List <string>() { "B3", "B1", "B5" }), CreateReader("R3", new List <string>() { "B2", "B6", "B7" }), CreateReader("R4") }; database = GetDatabase(readers); var service = new ReaderController(database, _logger); var result = service.Post("R4"); Assert.AreEqual(200, result.StatusCode); Assert.AreEqual(readers.Count, readersOutput.Count); for (int i = 0; i < readers.Count; i++) { Assert.AreEqual(true, ReaderEqual(readersOutput[i], readers[i])); } }
private void ReadBook() { if (_selectedBookInCategory == null) { return; } switch (_selectedBookInCategory.FileType) { case ".pdf": _readersContext = new ReadersContext(new PDFReader()); _readersContext.Read(SelectedBookInCategory.Path); break; case ".djvu": _readersContext = new ReadersContext(new DJVuReader()); _readersContext.Read(_selectedBookInCategory.Path); break; } }
public void Test6() { var readers = new List <Reader>() { CreateReader("R1", new List <string>() { "B1", "B2", "B3" }), CreateReader("R2", new List <string>() { "B3", "B1", "B5" }), CreateReader("R3", new List <string>() { "B2", "B6", "B7" }) }; var readerOutput = new ReaderOutput() { Nickname = "R2", Books = new List <string>() { "B3", "B1", "B5" } }; database = GetDatabase(readers); var service = new ReaderController(database, _logger); var result = service.Get("R2"); Assert.AreEqual(200, result.StatusCode); var output = (ReaderOutput)result.Value; Assert.AreEqual(true, OutputEqual(readerOutput, output)); }
public ReaderController(ReadersContext nDatabase, ILogger <ReaderController> nLogger) { database = nDatabase; _logger = nLogger; }
public void Initialize() { _logger = Mock.Of <ILogger <ReaderController> >(); database = GetDatabase(); }