public void GetReturnsNotFoundWhenFileDoesNotExist() { var addOnService = Mock.Of <AddOnService.IAddOnService>(s => s.GetAddOnFileAsync(1, 2) == Task.FromResult((AddOnService.AddOnFile)null) ); var controller = new AddOnFilesController(addOnService); var result = controller.Get(1, 2).Result; Assert.IsInstanceOfType(result, typeof(NotFoundResult), "Get should return not found when file does not exist"); }
public void GetReturnsResultFromAddOnService() { var file = new AddOnService.AddOnFile(); var addOnService = Mock.Of <AddOnService.IAddOnService>(s => s.GetAddOnFileAsync(1, 2) == Task.FromResult(file) ); var controller = new AddOnFilesController(addOnService); var result = controller.Get(1, 2).Result as OkNegotiatedContentResult <AddOnService.AddOnFile>; Assert.AreEqual(file, result.Content, "Get should return result from the addon service"); }
public void GetReturnsOkWhenFileFound() { var file = new AddOnService.AddOnFile(); var addOnService = Mock.Of <AddOnService.IAddOnService>(s => s.GetAddOnFileAsync(1, 2) == Task.FromResult(file) ); var controller = new AddOnFilesController(addOnService); var result = controller.Get(1, 2).Result; Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <AddOnService.AddOnFile>), "Get should return Ok when the file is found"); }