public async Task ScenarioFromCakeContextExtensionWithPatAndOrganization_SearchWorkItemById() { // Arrange var fakeResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(this._fileContent), Encoding.UTF8, "application/json") }; var fakeCakeContext = new FakeCakeContext(logBehaviour: () => new FakeCakeLog()); var fakeClient = new HttpClient(new FakeHttpMessageHandler(fakeResponse)) { BaseAddress = new Uri($"https://dev.azure.com/{this._organization}") }; var board = new AzureBoards(fakeClient); FieldInfo commandBehaviour = typeof(WorkItemCommand).GetRuntimeFields().Single(p => p.Name == "_getWorkItemByIdBehaviourAsync"); object originBehaviour = commandBehaviour.GetValue(typeof(WorkItemCommand)); // Act commandBehaviour.SetValue(typeof(WorkItemCommand), (Func <IBoard, string, Task <IWorkItem> >)((azureBoard, id) => board.GetWorkItemByIdAsync(id))); IWorkItem wit = await fakeCakeContext.GetWorkItemByIdAsync(this._pat, this._organization, this._witId); commandBehaviour.SetValue(typeof(WorkItemCommand), originBehaviour); // Assert Assert.IsType <WorkItem>(wit); Assert.Equal(this._witId, wit.Id); Assert.Equal(this._witState, wit.State); Assert.Equal(this._witTitle, wit.Title); Assert.Equal(this._witType, wit.Type); Assert.Equal(this._witDescription, wit.Description); Assert.Equal(this._witUrl, ((WorkItem)wit).Url); }
public async Task ScenarioFromCakeContextExtensionWithBoard_SearchWorkItemById() { // Arrange var fakeResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(this._fileContent), Encoding.UTF8, "application/json") }; var fakeCakeContext = new FakeCakeContext(logBehaviour: () => new FakeCakeLog()); var fakeClient = new HttpClient(new FakeHttpMessageHandler(fakeResponse)) { BaseAddress = new Uri($"https://dev.azure.com/{this._organization}") }; var board = new AzureBoards(fakeClient); // Act IWorkItem wit = await fakeCakeContext.GetWorkItemByIdAsync(board, this._witId); // Assert Assert.IsType <WorkItem>(wit); Assert.Equal(this._witId, wit.Id); Assert.Equal(this._witState, wit.State); Assert.Equal(this._witTitle, wit.Title); Assert.Equal(this._witType, wit.Type); Assert.Equal(this._witDescription, wit.Description); Assert.Equal(this._witUrl, ((WorkItem)wit).Url); }
public async Task ScenarioFromCakeContextExtensionWithBoard_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 fakeCakeContext.GetWorkItemByIdAsync(board, 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); }