Ejemplo n.º 1
0
        public void TestPasServiceInsertInvalidPas()
        {
            var newPas = new Pas
            {
                Id  = 10,
                Ime = "Lena",
                BrojZdravstveneKnjizice = "114190",
                Pol           = "Muški",
                Rasa          = "Akita",
                Obuka         = obukaRepo.Object.FindById(5),
                ObukaId       = 5,
                DatumRodjenja = new DateTime(2018, 11, 09)
            };
            var listaPasa = unitOfWork.Object.PasRepository.GetAll();
            var service   = new PasService(unitOfWork.Object);

            Assert.Throws <ArgumentOutOfRangeException>(() => service.Insert(newPas));
            unitOfWork.Verify(x => x.PasRepository.Insert(It.IsAny <Pas>()), Times.Never);
            unitOfWork.Verify(s => s.Save(), Times.Never);
            Assert.DoesNotContain(listaPasa, x => x.Id == newPas.Id);
        }
Ejemplo n.º 2
0
        public void TestPasServiceInsertPas()
        {
            var newPas = new Pas {
                Id  = 8,
                Ime = "Lena",
                BrojZdravstveneKnjizice = "000765",
                Pol           = "Ženski",
                Rasa          = "Nemački ovčar",
                Obuka         = obukaRepo.Object.FindById(5),
                ObukaId       = 5,
                DatumRodjenja = new DateTime(2018, 11, 09)
            };

            var service = new PasService(unitOfWork.Object);

            service.Insert(newPas);
            var result = service.GetAll();
            Pas pas    = service.FindById(newPas.Id);

            Assert.Equal(newPas.Id, pas.Id);
            unitOfWork.Verify(x => x.PasRepository.Insert(It.Is <Pas>(p => p.Ime == "Lena")), Times.Once);
            unitOfWork.Verify(x => x.Save(), Times.Once);
        }