Exemple #1
0
        public void EntitetPoId_Test(long id)
        {
            IQueryable <OsobaUredjaj> lista = new List <OsobaUredjaj>()
            {
                new OsobaUredjaj()
                {
                    Id = 1, Osoba = new Osoba()
                    {
                        Ime = "mirsan"
                    }
                },
                new OsobaUredjaj()
                {
                    Id = 4
                }
            }.AsQueryable();

            var mockDbSet = KancelarijaRepositoryTest.NapraviDbSet(lista);

            var optiionBilder = new DbContextOptionsBuilder <ToDoContext>();

            var mockContext = new Mock <ToDoContext>(optiionBilder.Options);

            mockContext.Setup(e => e.OsobaUredjaj).Returns(mockDbSet.Object);

            var repository = new OsobaUredjajRepository(mockContext.Object);
            var dobijas    = repository.EntitetPoId(id);

            Assert.Equal("mirsan", dobijas.Osoba.Ime);
        }
Exemple #2
0
        public IActionResult PoId(long id)
        {
            var osobaUredjaj = _repository.EntitetPoId(id);

            if (osobaUredjaj == null)
            {
                return(NotFound("Nema sa tim ID-em nista."));
            }

            return(Ok(_mapper.Map <OsobaUredjajDTO>(osobaUredjaj)));
        }