/// <summary> /// MongoDB logic to retrieve task dashoard /// </summary> /// <returns></returns> public async Task <TaskDashboard> GetDashboard() { //business logic goes here try { int completedTask = 0; int pendingTask = 0; var LstGroups = await _mongoCollectionGroup.FindAsync(FilterDefinition <TaskGroup> .Empty).Result.ToListAsync(); var LstTask = await _mongoCollection.FindAsync(FilterDefinition <TaskItem> .Empty).Result.ToListAsync(); TaskDashboard dashboard = new TaskDashboard(); dashboard.TotalGroups = LstGroups.Count; dashboard.TotalTask = LstTask.Count; LstTask.ForEach(item => { if (item.TaskStatus == TaskStatus.Finished) { completedTask++; } else if (item.TaskStatus == TaskStatus.On_Hold || item.TaskStatus == TaskStatus.Progress || item.TaskStatus == TaskStatus.Yet_To_Start) { pendingTask++; } }); dashboard.CompletedTask = completedTask; dashboard.PendingTask = pendingTask; return(dashboard); } catch (Exception exception) { throw exception; } }
public async Task ExceptionTestFor_GetTaskDashboard_FailWithException() { TaskDashboard result = null; try { //Action result = await _taskService.GetDashboard(); if (result == null && result.TotalGroups == 0 && result.TotalTask == 0 && result.PendingTask == 0 && result.CompletedTask == 0) { testResult = "ExceptionTestFor_GetTaskDashboard_FailWithException=" + "False"; // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Exception", Name = "ExceptionTestFor_GetTaskDashboard_FailWithException", expectedOutput = "False", weight = 2, mandatory = "False", desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } else { // Assert Assert.NotNull(result); } } catch (Exception exception) { var error = exception; testResult = "ExceptionTestFor_GetTaskDashboard_FailWithException=" + "True"; // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Exception", Name = "ExceptionTestFor_GetTaskDashboard_FailWithException", expectedOutput = "True", weight = 2, mandatory = "True", desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } }
private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { UserControl usc = null; GridMain.Children.Clear(); switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "ItemDashboard": //new ProjectDashboard(); usc = new ProjectMember(); GridMain.Children.Add(usc); break; case "ItemProject": usc = new ProjectDetailsPM(); GridMain.Children.Add(usc); break; case "ItemTask": usc = new TaskDashboard(); GridMain.Children.Add(usc); break; default: break; } }
public async Task FunctionalTestFor_GetTaskDashboard_Api() { try { TaskDashboard dashboard = null; HttpResponseMessage response = await _client.GetAsync("http://localhost:9090/api/Task/dashboard"); var status = response.EnsureSuccessStatusCode(); String taskResponse; if (status.IsSuccessStatusCode) { taskResponse = response.Content.ReadAsStringAsync().Result; dashboard = JsonConvert.DeserializeObject <TaskDashboard>(taskResponse); } if (dashboard.TotalGroups > 0 || dashboard.TotalTask > 0 || dashboard.PendingTask == 0 || dashboard.CompletedTask == 0) { testResult = "FunctionalTestFor_GetTaskDashboard_Api=" + "True".ToString(); // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Functional", Name = "FunctionalTestFor_GetTaskDashboard_Api", expectedOutput = "True".ToString(), weight = 2, mandatory = "True".ToString(), desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } else { // Assert Assert.NotNull(dashboard); } } catch (Exception exception) { var error = exception; testResult = "FunctionalTestFor_GetTaskDashboard_Api=" + "False".ToString(); // Write test case result in text file fileUtility.WriteTestCaseResuItInText(testResult); // Write test case result in xml file if (config["env"] == "development") { cases newcase = new cases { TestCaseType = "Functional", Name = "FunctionalTestFor_GetTaskDashboard_Api", expectedOutput = "False".ToString(), weight = 2, mandatory = "False".ToString(), desc = "na" }; await new FileUtility().WriteTestCaseResuItInXML(newcase); } } }