private void UpdateModel(string symbol, Action <PositionModel> action) { if (_posController.PositionOpened(symbol)) { var model = _posController.GetPosition(symbol); action(model); _posController.Refresh(model); } }
public void GetPosition(int id) { // Arrange // Act ActionResult <Position> position = _positionController.GetPosition(id).Result; // Assert if (position.Value != null) { Assert.Equal(1, position.Value.Id); } else { Assert.Equal("Microsoft.AspNetCore.Mvc.NotFoundResult", position.Result.ToString()); } }
public void Get_ShouldFail_GivenPositionDoesntExist() { // Given // PositionController over a mock service that would alway throw exceptions on Get & GetAsync _positionService.When(s => s.GetAsync(Arg.Any <Guid>())) .Do(v => throw new ItemNotFoundException(v[0].ToString(), "position")); var positionController = new PositionController( _positionService, _tenantIdProvider, Substitute.For <ILogger <PositionController> >()); var positionId = Guid.NewGuid(); // When // Put is called on the controller AsyncTestDelegate action = async() => await positionController.GetPosition(positionId); // Then // The controller should thrown ItemNotFoundException Assert.ThrowsAsync <ItemNotFoundException>(action); }
private Vector3 GetTargetPosition() { return(new Vector3(positionController.GetPosition(), transform.position.y, transform.position.z)); }