public void ThrowsExceptionIfDecimalPlacesIsZeroOrLess(int decimalPlaces) { var converter = new CurrencyConverter(); const decimal value = 1; const decimal exchangeRate = 1; Assert.Throws <ArgumentException>(() => converter.ConvertToGbp(value, exchangeRate, decimalPlaces)); }
public void ConvertToGdp_ConvertsCorrectly_2(decimal value, decimal rate, decimal exptected) { var converter = new CurrencyConverter(); int dps = 4; var actual = converter.ConvertToGbp(value, rate, dps); Assert.Equal(exptected, actual); }
public void ThrowsExceptionIfRateIsZero() { var converter = new CurrencyConverter(); const decimal value = 1; const decimal rate = 0; const int dp = 2; var ex = Assert.Throws <ArgumentException>( () => converter.ConvertToGbp(value, rate, dp)); //exptect to throw an exception }
public void ThrowsExceptionIfRateIsLessThanZero(decimal rate) { var converter = new CurrencyConverter(); const decimal value = 1; const int dp = 2; var ex = Assert.Throws <ArgumentException>( () => converter.ConvertToGbp(value, rate, dp)); }
[Fact] //marked as a test method public void ConvertToGdp_ConvertsCorrectly() { var converter = new CurrencyConverter(); decimal value = 3; decimal rate = 1.5m; int dp = 4; decimal exptected = 2; var actual = converter.ConvertToGbp(value, rate, dp); Assert.Equal(exptected, actual); }
public void ConvertToGbp_ConvertsCorrectly() { var converter = new CurrencyConverter(); decimal value = 3; decimal exchangeRate = 1.5m; decimal expected = 2m; int decimalPlaces = 4; var actual = converter.ConvertToGbp(value, exchangeRate, decimalPlaces); Assert.Equal(expected, actual); }
public void ConvertToGbp_ThrowsExceptionIfRateIsZero() { // Arrange var converter = new CurrencyConverter(); const decimal value = 1; const decimal rate = 0; const int dp = 2; // Act // Assert Should.Throw <ArgumentException>(() => converter.ConvertToGbp(value, rate, dp)).Message.ShouldStartWith("Exchange rate must be greater than zero"); }
public void ConvertToGbp_ConvertsCorrectly(decimal value, decimal rate, decimal expected) { // Arrange var converter = new CurrencyConverter(); int dps = 4; // Act var actual = converter.ConvertToGbp(value, rate, dps); // Assert actual.ShouldBe(expected); }
public void ThrowsExceptionIfRateIsZero() { var converter = new CurrencyConverter(); const decimal value = 1; const decimal rate = 0; // invalid value const int dp = 2; var ex = Assert.Throws <ArgumentException>( // ArgumentException throw is expected () => converter.ConvertToGbp(value, rate, dp)); // method execution should throw // Further assertions on the exception thrown, ex }
public void ConvertToGbp_ConvertsCorrectly() { var converter = new CurrencyConverter(); // system under test decimal value = 3; // parameters of the test decimal rate = 1.5m; int dp = 4; decimal expected = 2; // expected result var actual = converter.ConvertToGbp(value, rate, dp); // method execution Assert.Equal(expected, actual); // verification }
public IActionResult Convert(ConvertInputModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = _converter.ConvertToGbp( model.Value, model.ExchangeRate, model.DecimalPlaces); return(Json(new { Result = result })); }
public ViewResult Index(ConvertViewModel model) { if (!ModelState.IsValid) { return(View(model)); } model.Result = _converter.ConvertToGbp( model.Value, model.ExchangeRate, model.DecimalPlaces); return(View(model)); }