public void GetAllReturnsAllValuesNoFilter() { //Given the following setup var controller = new ListifyController(); var expectedValues = Enumerable.Range(0, 100); //Default value assigned is 100 //When the controller is called var values = controller.GetAll(new ListifyFilterModel()); var OkResult = values as OkObjectResult; //Then the response code should match the expected response code Assert.Equal(200, OkResult.StatusCode); Assert.True(((IEnumerable <int>)OkResult.Value).SequenceEqual(expectedValues)); }
public void GetAllRequestValidation(int?minValue, int?maxValue, int expectedResponseCode) { //Given the following setup var controller = new ListifyController(); //When the controller is called var response = controller.GetAll(new ListifyFilterModel() { MinValue = minValue, MaxValue = maxValue }); var statusCode = response as IStatusCodeActionResult; //Then the response code should match the expected response code Assert.Equal(expectedResponseCode, statusCode.StatusCode); }
public void GetReturnsValue(int index, int?minValue, int?maxValue, int expectedResponseCode) { //Given the following values var controller = new ListifyController(); //When the controller is called var response = controller.Get(index, new ListifyFilterModel() { MinValue = minValue, MaxValue = maxValue }); var statusCode = response as IStatusCodeActionResult; var responseObject = response as OkObjectResult; //Then the response code should match the expected response code Assert.Equal(expectedResponseCode, statusCode.StatusCode); if (statusCode.StatusCode == 200) { Assert.Equal(minValue.HasValue ? minValue.Value + Math.Abs(index) : index + Math.Abs(index), (int)responseObject.Value); } }