Пример #1
0
        public bool Add(AddPublisherDTO dto)
        {
            var publisher = GetPublisher(dto.Name);

            if (publisher == null)
            {
                this.db.Publishers.Add(new Publisher
                {
                    Name       = dto.Name,
                    URLAddress = dto.URLAddress,
                });
            }

            int count = this.db.SaveChanges();

            return(count != 0);
        }
Пример #2
0
        public void AddPublisher_WithCorrectData_ShouldSuccessfullyAddPublisher()
        {
            string errorMessagePrefix = "PublisherService Add() method does not work properly.";

            var context = LibraaryDbContextInMemoryFactory.InitializeContext();

            this.publisherService = new PublisherService(context);

            AddPublisherDTO publisherDto = new AddPublisherDTO()
            {
                Name       = "Testt1",
                URLAddress = "https/facebook.com/"
            };

            bool actualResult = this.publisherService.Add(publisherDto);

            Assert.True(actualResult, errorMessagePrefix);
        }