public async Task TestGetIDSuccessfully() { using (var context = new CryptoCognizantContext(options)) { ExchangesController exchangesController = new ExchangesController(context); ActionResult <Exchange> result = await exchangesController.GetExchange(0); Assert.IsNotNull(result); } }
public async Task TestPutExchangeNoContentStatusCode() { using (var context = new CryptoCognizantContext(options)) { string newPairs = "BTC, NAV, LTC"; Exchange exchange1 = context.Exchange.Where(x => x.Pairs == exchanges[0].Pairs).Single(); exchange1.Pairs = newPairs; ExchangesController exchangesController = new ExchangesController(context); IActionResult result = await exchangesController.PutExchange(exchange1.ExchangeId, exchange1) as IActionResult; Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NoContentResult)); } }
public async Task TestDeleteSuccessfully() { using (var context = new CryptoCognizantContext(options)) { ExchangesController exchangesController = new ExchangesController(context); ActionResult <IEnumerable <Exchange> > result1 = await exchangesController.GetExchange(); ActionResult <Exchange> delete = await exchangesController.DeleteExchange(0); ActionResult <IEnumerable <Exchange> > result2 = await exchangesController.GetExchange(); // Assert that exchange list changes after exchange is deleted Assert.AreNotEqual(result1, result2); } }
public async Task TestPostSuccessfully() { using (var context = new CryptoCognizantContext(options)) { ExchangesController exchangesController = new ExchangesController(context); Exchange exch = new Exchange() { ExchangeId = 3, Pairs = "USD, USDT, NZD, AUD" }; ActionResult <IEnumerable <Exchange> > result1 = await exchangesController.GetExchange(); ActionResult <Exchange> post = await exchangesController.PostExchange(exch); ActionResult <IEnumerable <Exchange> > result2 = await exchangesController.GetExchange(); // Assert that exchange list changes after new exchange is posted Assert.AreNotEqual(result1, result2); } }