public static void ThreadCallRead(Object threadContext) { ToRead threadValue = (ToRead)threadContext; lock (fs) { fs.Seek(threadValue.offset, SeekOrigin.Begin); fs.Read(threadValue.data, threadValue.index, threadValue.count); }; IO.Monitor.Output("HDD raed thread run"); lock (fs) { cCTEndRTs++; if (cCTEndRTs == countRead) { cCTEndRTs = 0; fs.Close(); if (ReadHandler != null) { ReadHandler(); ReadHandler = null; } } } }
public void GivenValidToReadDetails_WhenDeleteBookFromBookShelf_ReturnToBookProfile() { using (var scope = Container.BeginLifetimeScope()) { // Arrange _bookController = scope.Resolve <BooksController>(); BookService bookService = scope.Resolve <BookService>(); ToRead toRead = new ToRead(); toRead.UserId = 289; toRead.BookId = 11; _bookController.AddBookToBookShelf(toRead); // Act var result = _bookController.DeleteBookFromBookShelf(toRead) as RedirectToRouteResult; // Assert Assert.IsNotNull(result); var values = result.RouteValues.Values; Assert.IsTrue(values.Contains(11)); Assert.IsTrue(values.Contains(controllerName)); Assert.IsTrue(values.Contains("BookProfile")); Assert.IsNull(bookService.GetABookReview(289, 11)); // cleanup, assert it's been successful } }
public void GivenValidToReadDetails_WhenAddBookToBookShelf_ReturnToBookProfile() { using (var scope = Container.BeginLifetimeScope()) { // Arrange _bookController = scope.Resolve <BooksController>(); BookService bookService = scope.Resolve <BookService>(); ToRead toRead = new ToRead(); toRead.UserId = 289; toRead.BookId = 11; // Act var result = _bookController.AddBookToBookShelf(toRead) as RedirectToRouteResult; // Assert Assert.IsNotNull(result); var values = result.RouteValues.Values; Assert.IsTrue(values.Contains(11)); Assert.IsTrue(values.Contains(controllerName)); Assert.IsTrue(values.Contains("BookProfile")); Assert.IsTrue(bookService.RemoveBookFromToRead(toRead)); // undo creation addition to database } }
public ActionResult AddBookToBookShelf(ToRead bookToRead) { bool isBookAddedToShelf = _bookService.AddBookToReadShelf(bookToRead); ViewBag.Message = "Book Profile"; return(RedirectToAction("BookProfile", "Books", new { bookId = bookToRead.BookId })); }
public ActionResult DeleteBookFromBookShelf(ToRead bookToRead) { bool isBookRemoved = _bookService.RemoveBookFromToRead(bookToRead); ViewBag.Message = "Book Profile"; return(RedirectToAction("BookProfile", "Books", new { bookId = bookToRead.BookId })); }
public bool IsOnBookShelf(ToRead bookToRead) { var booksOnShelf = from booksToRead in _toReadRepository.GetListOf() where booksToRead.BookId == bookToRead.BookId && booksToRead.UserId == bookToRead.UserId select booksToRead; return(booksOnShelf.ToList().Count == 1); }
/// <summary> /// Выбрать метод чтения. /// </summary> /// <param name="choice"> true - чтение из файла. false - чтение из консоли. </param> public void ChooseMethodOfInput(bool choice = false) { if (choice) { toRead = ReadFromFiles; } else { toRead = ReadFromConsole; } }
private static object GetValue(ToRead current) { if (current.Value == null) { return(null); } if (current.Type.IsGenericType && current.Type.IsValueType && current.Type.GetGenericTypeDefinition() == typeof(Nullable <>)) { return(Convert.ChangeType(current.Value, current.Type.GetGenericArguments()[0])); } return(current.Value); }
public void GivenToRead_WhenIsBookOnToReadShelf_ReturnTrue() { ToRead toRead = new ToRead(); toRead.BookId = 11; toRead.UserId = 289; using (var scope = Container.BeginLifetimeScope()) { // Arrange _bookService = scope.Resolve <BookService>(); var result = _bookService.IsOnBookShelf(toRead); Assert.IsNotNull(result); Assert.AreEqual(result, true); } }
public bool RemoveBookFromToRead(ToRead bookToRead) { return(_toReadRepository.Delete(bookToRead)); }
public bool AddBookToReadShelf(ToRead bookToRead) { return(_toReadRepository.Create(bookToRead)); }