Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Studio studio = ss.GetStudioById(id);

            ss.DeleteStudio(studio);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public void DeleteStudio_ShouldThrowException_WhenNoStudioIsFound(string name)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();

            var listOfStudios = new List <Studio>();

            repositoryMock.Setup(r => r.Entities).Returns(listOfStudios.AsQueryable <Studio>);
            var service = new StudioService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object);

            Assert.Throws <NullReferenceException>(() => service.DeleteStudio(name));
        }
Ejemplo n.º 3
0
        public void DeleteStudio_ShouldCallUnitOfWork_WhenStudioIsFound(string name)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();
            var studio         = new Studio(name, null);
            var listOfStudios  = new List <Studio>();

            listOfStudios.Add(studio);
            repositoryMock.Setup(r => r.Entities).Returns(listOfStudios.AsQueryable <Studio>);

            var service = new StudioService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object);

            service.DeleteStudio(name);

            unitOfWorkMock.Verify(u => u.Commit(), Times.Once);
        }
Ejemplo n.º 4
0
        public void DeleteStudio_ShouldCallEntitiesOfReository_WhenParametersAreCorrect(string name)
        {
            var repositoryMock = new Mock <IRepository <Studio> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var factoryMock    = new Mock <IStudioFactory>();

            var listOfStudios = new List <Studio>();

            listOfStudios.Add(new Studio(name, null));

            repositoryMock.Setup(r => r.Entities).Returns(listOfStudios.AsQueryable <Studio>);
            var service = new StudioService(repositoryMock.Object, unitOfWorkMock.Object, factoryMock.Object);

            service.DeleteStudio(name);

            repositoryMock.Verify(r => r.Entities, Times.Once);
        }
Ejemplo n.º 5
0
 public async Task <Studio> Delete(int id)
 {
     return(await studioService.DeleteStudio(id));
 }