public void GetByIdTest() { var mock = new Mock <IAlergenRepository>(); mock.Setup(x => x.GetAsync("maja123")) .ReturnsAsync(Alergens[0]); var repository = mock.Object; var service = new AlergenService(repository); var result = service.GetAsync("maja123"); Assert.IsNotNull(result.Result); Assert.AreEqual((result.Result).Abrv, "glu"); }
public void GetAllTest() { var filter = new AlergenFilter("Abrv", 1, 3); var mock = new Mock <IAlergenRepository>(); mock.Setup(x => x.GetAsync(filter)) .ReturnsAsync(Alergens); var repository = mock.Object; var service = new AlergenService(repository); var result = service.GetAsync(filter); Assert.IsNotNull(result.Result); Assert.AreEqual((result.Result)[0].Abrv, "glu"); }