public async Task ScenarioFromBoardExtension_SearchTaskById() { // Arrange HttpResponseMessage fakeResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(this._fileContent), Encoding.UTF8, "application/json") }; FakeCakeContext fakeCakeContext = new FakeCakeContext(logBehaviour: () => new FakeCakeLog()); HttpClient fakeClient = new HttpClient(new FakeHttpMessageHandler(fakeResponse)) { BaseAddress = new Uri("https://app.asana.com/api/1.0") }; Asana board = new Asana(fakeClient); // Act IWorkItem wit = await board.GetWorkItemByIdAsync(this._taskid); // Assert Assert.IsType <Models.Task>(wit); Assert.Equal(this._taskid, wit.Id); Assert.Equal(this._taskState, ((Models.Task)wit).State); Assert.Equal(this._taskTitle, wit.Title); Assert.Equal(this._taskType, wit.Type); Assert.Equal(this._taskDescription, wit.Description); }
public async Task ScenarioFromCakeContextExtensionWithPatAndOrganization_SearchTaskById() { // Arrange HttpResponseMessage fakeResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(this._fileContent), Encoding.UTF8, "application/json") }; FakeCakeContext fakeCakeContext = new FakeCakeContext(logBehaviour: () => new FakeCakeLog()); HttpClient fakeClient = new HttpClient(new FakeHttpMessageHandler(fakeResponse)) { BaseAddress = new Uri("https://app.asana.com/api/1.0") }; Asana board = new Asana(fakeClient); FieldInfo commandBehaviour = typeof(BoardCommandAliases).GetRuntimeFields().Single(p => p.Name == "_getWorkItemByIdBehaviourAsync"); object originBehaviour = commandBehaviour.GetValue(typeof(BoardCommandAliases)); // Act commandBehaviour.SetValue(typeof(BoardCommandAliases), (Func <IBoard, string, Task <IWorkItem> >)((azureBoard, id) => board.GetWorkItemByIdAsync(id))); IWorkItem wit = await fakeCakeContext.GetTaskByIdAsync(this._pat, this._taskid); commandBehaviour.SetValue(typeof(BoardCommandAliases), originBehaviour); // Assert Assert.IsType <Models.Task>(wit); Assert.Equal(this._taskid, wit.Id); Assert.Equal(this._taskState, ((Models.Task)wit).State); Assert.Equal(this._taskTitle, wit.Title); Assert.Equal(this._taskType, wit.Type); Assert.Equal(this._taskDescription, wit.Description); }