public void AddTest()
        {
            //arrange
            SetUp();
            Book book = new Book();

            mock.Setup(x => x.Add(book));

            //act
            var result = controller.Add(book);

            //assert
            Assert.IsInstanceOf <OkResult>(result);
        }
Exemple #2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            //checking for correct data input
            if (tb_title.Text == "")
            {
                MessageBox.Show("You have to input at least a title.");
                tb_title.Focus();
            }
            else
            {
                //checking if the previous query contained the previously added data
                if (parameters.Count != 0 && (parameters["title"].ToString() == tb_title.Text || parameters["isbn"] == tb_isbn))
                {
                    MessageBox.Show("You have already added a record with the same title/ISBN!", "Information");
                    ClearTextBoxes();
                }
                else
                {
                    UpdateParameters();
                    bool success = BookController.Add(parameters);

                    if (success == true)
                    {
                        MessageBox.Show("Record successfully added.", "Information");
                    }
                    else
                    {
                        MessageBox.Show("Adding record failed.", "Information");
                    }
                }
            }
        }
Exemple #3
0
        private void AddBookBtn_Click(object sender, RoutedEventArgs e)
        {
            InitDataSource(ref bookItems, Mapper.BooksToBookViewModels, bookController.Get);

            AddBook addBook = new AddBook(
                sectionItems   = InitItems(ref sectionItems, Mapper.SectionsToSectionViewModels, sectionController.Get),
                publisherItems = InitItems(ref publisherItems, Mapper.PublishersToPublisherViewModels, publisherController.Get)
                );

            if (addBook.ShowDialog().Value)
            {
                string             name        = addBook.Name.Text;
                string             description = addBook.Description.Text;
                Models.Condition   condition   = (Models.Condition)Enum.Parse(typeof(Models.Condition), addBook.Condition.Text);
                SectionViewModel   sectionVM   = addBook.SelectedSectionItem;
                PublisherViewModel publisherVM = addBook.SelectedPublisherItem;

                if (name != null && sectionVM != null && publisherVM != null)
                {
                    Models.Section section   = sectionController.GetById(sectionVM.Id);
                    Publisher      publisher = publisherController.GetById(publisherVM.Id);
                    Book           book      = new Book(name, description, condition, section, publisher);
                    bookController.Add(book);
                    bookItems.Add(Mapper.BookToBookViewModel(book));
                    return;
                }
            }
        }
Exemple #4
0
        public void Get_WhenCalled_ReturnsOkResult()
        {
            // Act
            var okResult = _controller.Add();

            // Assert
            Assert.IsType <OkObjectResult>(okResult);
        }
Exemple #5
0
        private void btnAddBook_Click(object sender, EventArgs e)
        {
            CheckComboboxes();
            CheckBoxControls();
            NumericControls();
            currentBook.BookName       = txtBookName.Text;
            currentBook.PublishingYear = (int)nudPublishingYear.Value;
            currentBook.Summary        = txtSummary.Text;


            try
            {
                bool result = _bookController.Add(currentBook);

                if (result)
                {
                    MessageBox.Show("Kitap ekleme başarılı");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }