public void Test_AddPublisher_With_Same_CompanyName()
        {
            //arrange
            PublisherService service = new PublisherService(_unitOfWork.Object);
            PublisherDTO publisher = new PublisherDTO() { CompanyName = "name1", PublisherId = 1};

            //act
            service.AddPublisher(publisher);
        }
        public void Test_AddPublisher_Call_Insert()
        {
            //arrange
            PublisherService service = new PublisherService(_unitOfWork.Object);
            PublisherDTO publisher = new PublisherDTO() { CompanyName = "name", PublisherId = 1 };

            //act
            service.AddPublisher(publisher);

            //assert
            _publisherRepository.Verify( p => p.Insert(It.IsAny<Publisher>()), Times.Once() );
        }
Esempio n. 3
0
 private bool NotNullPublisherProperties(PublisherDTO publisher, bool isEditMode = false)
 {
     if (string.IsNullOrEmpty(publisher.CompanyName))
         throw new ArgumentNullException("Company name can not be null or empty");
     if (string.IsNullOrEmpty(publisher.Description))
         throw new ArgumentNullException("Description can not be null or empty");
     if (string.IsNullOrEmpty(publisher.HomePage))
         throw new ArgumentNullException("Home page can not be null or empty");
     if (isEditMode && publisher.PublisherId <= 0)
         throw new ArgumentException("Invalid publisher Id");
     return true;
 }
Esempio n. 4
0
 public void AddPublisher(PublisherDTO publisher)
 {
     if ( GetPublisherByCompanyName(publisher.CompanyName) != null )
         throw new ArgumentException("You can not add publisher with same company name");
     _unitOfWork.Publishers.Insert( Mapper.Map<PublisherDTO, Publisher>(publisher) );
 }