public void ShouldReturnBadRequest_WhenParamsMissing() { var response = feeController.Get(new FeeCalculateRequest { }); var validationResult = response as BadRequestObjectResult; Assert.AreEqual(400, validationResult.StatusCode); }
public void GetWithName_NotFoundTest() { //Arrange const string searchingName = "A"; repository.Setup(r => r.GetByNameAsync(searchingName)).Returns(Task.FromResult <ServerFormula>(null)); controller = new CalculatorController(repository.Object, monitor.Object); //Act var result = controller.Get(searchingName).Result as NotFoundResult; //Assert repository.Verify(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public void GetWithIdTest() { //Arrange const int searchingId = 1; var formula = new ServerFormula() { FormulaId = searchingId }; repository.Setup(r => r.GetByIdAsync(searchingId)).Returns(Task.FromResult(formula)); controller = new CalculatorController(repository.Object, monitor.Object); //Act var result = controller.Get(searchingId).Result as JsonResult <ServerFormula>; var model = result.Content; //Assert repository.Verify(); Assert.IsNotNull(result); Assert.AreSame(formula, model); }
public void GetTest() { //Arrange IEnumerable <ServerFormula> formulas = new List <ServerFormula> { new ServerFormula(), new ServerFormula() }; repository.Setup(r => r.GetAllAsync(null, false, false, false)).Returns(Task.FromResult(formulas)); controller = new CalculatorController(repository.Object, monitor.Object); //Act var result = controller.Get().Result as JsonResult <IEnumerable <ServerFormula> >; var model = result.Content; //Assert repository.Verify(); Assert.IsNotNull(result); Assert.AreSame(formulas, model); }