public void KreffFormulaTest_NotError() { // arrange var res = new KreffFormulaQuery { Height = 180, LenСarpus = 5, Age = 25 }; // act var handler = new KreffFormulaHandler(); var result = handler.Handle(res).Result; // assert Assert.AreEqual(66.42, result.CalculationResult); }
public void KreffFormulaTest_MoreError() { // arrange var modelMore = new KreffFormulaQuery { Height = 351, LenСarpus = 55, Age = 301 }; // act var handler = new KreffFormulaHandler(); var errorModel = handler.Handle(modelMore).Exception.GetErrorListResponseFromException(); // assert Assert.IsTrue(errorModel != null); Assert.IsTrue(errorModel.Errors.Count == 3); Assert.IsTrue(errorModel.Errors.Contains(KreffFormulaQueryValidator.HeightIncorrectMessage)); Assert.IsTrue(errorModel.Errors.Contains(KreffFormulaQueryValidator.AgeIncorrectMessage)); Assert.IsTrue(errorModel.Errors.Contains(KreffFormulaQueryValidator.LenСarpusIncorrectMessage)); }
public async Task <KreffFormulaResponse> Calculate(KreffFormulaQuery query) { return(await _handler.Handle(query)); }