public void GetReturns404() { // Arrange var mockRepository = new Mock <IKosarkasRepository>(); var controller = new KosarkasiController(mockRepository.Object); // Act IHttpActionResult actionResult = controller.Get(51); // Assert Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void GetReturns200AndObject() { // Arrange var mockRepository = new Mock <IKosarkasRepository>(); mockRepository.Setup(x => x.GetById(50)).Returns(new Kosarkas { Id = 50, Naziv = "Test50", Godina = 1980, BrojUtakmica = 50, ProsecanBrojPoena = 10.8m, KlubId = 1 }); var controller = new KosarkasiController(mockRepository.Object); // Act IHttpActionResult actionResult = controller.Get(50); var contentResult = actionResult as OkNegotiatedContentResult <Kosarkas>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(50, contentResult.Content.Id); }