Exemplo n.º 1
0
        public void DeleteGenre_WhenObjectExists()
        {
            //Arrange
            genre.IsDeleted = false;

            genreRepoMock
            .Setup(repo => repo.Delete(It.IsAny <Genre>()))
            .Callback <Genre>((genre) =>
            {
                predifinedListOfGenres.Remove(genre);
            });

            unitOfWork.Setup(x => x.Genres)
            .Returns(genreRepoMock.Object);

            genreRepoMock.Setup(repo => repo.AllAndDeleted())
            .Returns(predifinedListOfGenres.AsQueryable());

            //Act
            var command = new GenreServices(unitOfWork.Object);

            command.DeleteGenre(genre.Name);

            //Assert
            Assert.AreEqual(0, predifinedListOfGenres.Count);
        }
Exemplo n.º 2
0
        private void cmdSave_Click(object sender, RoutedEventArgs e)
        {
            IList objSource = GenreServices.GetGenres(_itemsType);
            IList objTarget = (IList)dtgData.DataContext;

            if (objSource != null)
            {
                foreach (Genre item in objSource)
                {
                    Genre type = item;
                    if (!objTarget.Contains(type))
                    {
                        GenreServices.DeleteGenre(item, _itemsType);
                    }
                }
            }
            foreach (Genre item in objTarget)
            {
                if (string.IsNullOrWhiteSpace(item.RealName) == false || string.IsNullOrWhiteSpace(item.DisplayName) == false)
                {
                    if (string.IsNullOrWhiteSpace(item.RealName))
                    {
                        item.RealName = item.DisplayName;
                    }

                    if (string.IsNullOrWhiteSpace(item.RealName) == false && _added.Contains(item.RealName) == false)
                    {
                        new GenreServices().AddGenre(item, _itemsType);
                        _added.Add(item.RealName);
                    }
                }
            }

            Close();
        }
Exemplo n.º 3
0
 public ActionResult DeleteGenre(int id)
 {
     _genreServices = new GenreServices();
     _genreServices.DeleteGenre(id);
     return(RedirectToAction("ListGenre"));
 }
Exemplo n.º 4
0
 public ActionResult Delete(Genre genre)
 {
     genreServices.DeleteGenre(genre);
     return(RedirectToAction("Index"));
 }