Beispiel #1
0
        protected void CheckAndAddNews(List <Channel> news)
        {
            ChannelsContext                 con          = new ChannelsContext();
            RepositoryService <Channel>     channels     = new RepositoryService <Channel>(con);
            RepositoryService <ChannelItem> channelItems = new RepositoryService <ChannelItem>(con);

            foreach (var item in channelItems.GetAll())
            {
                item.State = false;
                channelItems.Edit(item);
            }

            channelItems.Save();

            foreach (var item in news)
            {
                bool found = false;

                foreach (var item2 in channels.GetAll())
                {
                    if (item2.Link == item.Link)
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    channels.Add(item);
                }
            }
        }
        public void RepositoryService_Add_Throws_On_Null_Repository()
        {
            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<ArgumentNullException>(() => _service.Add(null));
        }
        public void RepositoryService_Add_Calls_Repository_Add_Method_With_The_Same_Repository_Object_It_Recieved()
        {
            // Create test data
            var newRepository = new Repository
                                    {
                                        Name = "Foo",
                                        Address = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Repository>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Repository>()).Returns(mockRepository.Object);

            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newRepository);

            //Assert
            mockRepository.Verify(r => r.Add(newRepository));
        }
Beispiel #4
0
 /// <summary>
 /// Add a new card to the database
 /// </summary>
 /// <param name="card"></param>
 public void AddCard(CardDetails card)
 {
     _contextService.Add(card);
 }
        public void RepositoryService_Add_Calls_UnitOfWork_Commit_Method()
        {
            // Create test data
            var newRepository = new Repository
                                    {
                                        Name = "Foo",
                                        Address = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Repository>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Repository>()).Returns(mockRepository.Object);

            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newRepository);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
 /// <summary>
 /// Add new transaction to the database
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public void CreateTransaction(Transaction entity)
 {
     _contextService.Add(entity);
 }
Beispiel #7
0
 /// <summary>
 /// Add a donation to the database
 /// </summary>
 /// <param name="entity"></param>
 public void AddDonation(Donation entity)
 {
     _contextService.Add(entity);
 }