public async Task TestDivide(int x, int y, int sum) { #region arrange var imp = new MyImportantClass(); #endregion #region act var res = await imp.Divide(x, y); #endregion #region assert Assert.Equal(res, sum); #endregion }
public async Task TestDivide0(int x, int y) { #region arrange var imp = new MyImportantClass(); #endregion #region act var ex = await Record.ExceptionAsync(() => imp.Divide(x, y)); #endregion #region assert Assert.NotNull(ex); Assert.IsType <ArgumentException>(ex); #endregion }
public async Task <ActionResult <KeyValuePair <string, int> > > DivAsPOST([FromBody] MyDiv mysum) { Console.WriteLine(nameof(DivAsPOST)); try { var imp = new MyImportantClass(); var ret = await imp.Divide(mysum.x, mysum.y); return(new KeyValuePair <string, int>("result", ret)); } catch (Exception ex) { //TODO: log return(BadRequest("error:" + ex.Message)); } }