public async Task GetSampleSetsByIdShouldGetSampleSet() { var sampleId = 1; var sample = new SampleSets { Id = sampleId }; _projectBLMock.Setup(x => x.GetSampleSetsByIDAsync(It.IsAny <int>())).Returns(Task.FromResult(sample)); var sampleController = new SampleSetsController(_projectBLMock.Object); var result = await sampleController.GetSampleSetsByIDAsync(sampleId); Assert.Equal(sampleId, ((SampleSets)((OkObjectResult)result).Value).Id); _projectBLMock.Verify(x => x.GetSampleSetsByIDAsync(sampleId)); }
public async Task GetSampleSetsByID_ShouldReturnNotFound_WhenIDIsInvalid() { //arrange int id = 1; SampleSets sampleSets = null; _projectBLMock.Setup(i => i.GetSampleSetsByIDAsync(id)).ReturnsAsync(sampleSets); SampleSetsController sampleSetsController = new SampleSetsController(_projectBLMock.Object); //act var result = await sampleSetsController.GetSampleSetsByIDAsync(id); //assert Assert.IsType <NotFoundResult>(result); }