public void Controller_Returns_NotFound_For_Nonexisting_Currency() { // Arrange var currenciesController = new CurrenciesController(new StubCurrencyReferenceDataRepository()); // Act var response = currenciesController.Get("YYY") as NegotiatedContentResult<string>; // Assert // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); Assert.AreEqual("A currency with code 'YYY' was not found.", response.Content); }
public void Controller_Returns_All_Currencies() { // Arrange var currenciesController = new CurrenciesController(new StubCurrencyReferenceDataRepository()); // Act var response = currenciesController.Get() as OkNegotiatedContentResult<IEnumerable<Currency>>; // Assert if (response != null) { var currencies = response.Content; Assert.AreEqual(2, currencies.Count()); } }
public void Controller_Returns_Existing_Currency() { // Arrange var currenciesController = new CurrenciesController(new StubCurrencyReferenceDataRepository()); // Act var response = currenciesController.Get("GBP") as OkNegotiatedContentResult<Currency>; // Assert if (response != null) { var currency = response.Content; Assert.AreEqual("GBP", currency.CurrencyChar3Code); Assert.AreEqual(00, currency.CurrencyNumberCode); Assert.AreEqual("British Pound", currency.CurrencyName); Assert.AreEqual(2, currency.NumberOfDigits); } }