private void CreateBook(object sender, RoutedEventArgs e) { Bctr.CreateBook(txtTitle.Text, txtAuthor.Text, txtIsbn.Text, txtPic.Text); txtTitle.Clear(); txtAuthor.Clear(); txtIsbn.Clear(); txtPic.Clear(); FillViewList(); }
public async Task CreateBookCheckReturnOk_Test() { _bookService.Setup(service => service.CreateAsync(_bookModelDTO)).Returns(async() => { await Task.CompletedTask; }); var actionResult = await _bookController.CreateBook(_bookModelDTO); var contentResult = actionResult as IStatusCodeActionResult; Assert.AreEqual(StatusCodes.Status200OK, contentResult.StatusCode); }
public void Create_ValidObjectPassed_ReturnsCreatedResponse() { // Arrange CreateBookDto dto = new CreateBookDto() { Name = "C# Book", PageCount = 425, BookType = "Learning" }; // Act var result = _controller.CreateBook(dto); // Assert Assert.IsType <CreatedResult>(result); }
public void CreateBookTest() { using (var context = new BookContext(options)) { ///Arrange var controller = new BookController(null, context); Book book = new Book() { Id = Guid.NewGuid(), Name = "Тест", Author = "Тест", Given = false, DatePublished = DateTime.ParseExact("01/01/1866", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) }; //Act var tag = controller.CreateBook(book); var result = context.Books.ToList(); //Assert Xunit.Assert.Equal(5, result.Count); } }
public void CreateBook_Unsuccessfull() { // Arrange Book book = new Book { BookId = 4, BookName = "TestBook", Description = "Checking X unit test", TenantId = 1, }; bookServiceMoq.Setup(c => c.CreateBook(book)).Returns(false); // Act var controller = new BookController(logger.Object, bookServiceMoq.Object, userService.Object, mailService.Object, taskService.Object); var response = controller.CreateBook(book); // Assert var OkResult = response as OkObjectResult; Assert.NotNull(OkResult); Assert.Equal("Book not created", OkResult.Value); bookServiceMoq.Verify(c => c.CreateBook(book), Times.Once()); }
public void CreateBook_Successfull() { Book book = new Book { BookId = 4, BookName = "TestBook", Description = "Checking X unit test", TenantId = 1, }; bookServiceMoq.Setup(c => c.CreateBook(book)).Returns(true); // Act var controller = new BookController(logger.Object, bookServiceMoq.Object, userService.Object, mailService.Object, taskService.Object); var response = controller.CreateBook(book); // Assert Assert.IsType <OkObjectResult>(response); var okResult = response as OkObjectResult; Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); Assert.Equal("Book created successfully", okResult.Value); bookServiceMoq.Verify(c => c.CreateBook(book), Times.Once()); }
private void btnSave_Click(object sender, EventArgs e) { bookController.CreateBook(txtFirstName.Text, txtLastName.Text, txtTitle.Text, txtIsbn.Text); }
public void CreateBook_ValidBook_ReturnResponseDataWithTrue() { var response = _bookController.CreateBook(_beautyAndTheBeast); var responseData = (ResponseData)response.Data; Assert.That(responseData.Status, Is.True); Assert.That(responseData.Message, Does.Contain("Successfully created")); }