public void Get_CorrectOperationId_Returns_Operation() { IEnumerable<Operation> fakeOperation = GetOperations(); _operationRepository.Setup(x => x.GetAllAsync()).ReturnsAsync(fakeOperation); OperationsController controller = new OperationsController(_operationRepository.Object) { Request = new HttpRequestMessage() { Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } } }; var operation = controller.Get(4); Assert.IsNotNull(operation); Assert.AreEqual(4, operation.Id, "Got wrong number of Operations"); }
public void Get_InvalidOperationId_Return_NotFound() { IEnumerable<Operation> fakeOperation = GetOperations(); _operationRepository.Setup(x => x.GetAllAsync()).ReturnsAsync(fakeOperation); OperationsController controller = new OperationsController(_operationRepository.Object) { Request = new HttpRequestMessage() { Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } } }; var operation = controller.Get(4); Assert.IsInstanceOf<NotFoundResult>(operation.Result); }