Example #1
0
        public void TestZadatakServiceDeleteInvalidIdZadatak()
        {
            var service    = new ZadatakService(unitOfWork.Object);
            int idToDelete = 99;

            Assert.Throws <Exception>(() => service.Delete(idToDelete));
            unitOfWork.Verify(s => s.ZadatakRepository.Delete(idToDelete), Times.Never);
            unitOfWork.Verify(s => s.Save(), Times.Never);
        }
Example #2
0
        public void TestZadatakServiceDeleteZadatak()
        {
            var service    = new ZadatakService(unitOfWork.Object);
            int idToDelete = 1;

            service.Delete(idToDelete);
            var result = unitOfWork.Object.ZadatakRepository.FindById(idToDelete);
            var zadaci = unitOfWork.Object.ZadatakRepository.GetAll();

            Assert.Null(result);
            Assert.DoesNotContain(zadaci, x => x.Id == idToDelete);
            unitOfWork.Verify(s => s.ZadatakRepository.Delete(idToDelete), Times.Once);
            unitOfWork.Verify(s => s.Save(), Times.Once);
        }