public void GivenAnInvalidUser_DoesNotAddTaskToDatabase() { // Arrange var dto = new AddTaskRequest() { PlayerId = TestConstants.AllOnesGuid }; // Act var result = _controller.AddTask(dto); // Assert Assert.IsInstanceOf <NotFoundResult>(result.Result); }
private async void btnAdd_Click(object sender, RoutedEventArgs e) { //button add new task on the add task grid TextRange textRange = new TextRange( // TextPointer to the start of content in the RichTextBox. rtbDescription2.Document.ContentStart, // TextPointer to the end of content in the RichTextBox. rtbDescription2.Document.ContentEnd ); if (txtName.Text != "" && textRange.Text != "" && dtpEndDate.Text != "") { TC.AddTask(P, new Task { taskName = txtName.Text, TaskDescription = textRange.Text, endDate = Convert.ToDateTime(dtpEndDate.Text), startDate = DateTime.Now }, MC.SearchMemberByDisplayName(cbAssignTo.SelectedItem.ToString())); txtName.Text = ""; rtbDescription1.SelectAll(); rtbDescription1.Selection.Text = ""; dtpEndDate.Text = ""; var ProjectView = new ProjectView(); Content = ProjectView; } else { await metroWindow.ShowMessageAsync("Atention", "Complete the fields first"); } }
//public class StaticWrapper : IStaticWrapper //{ // public Task SendAsync(IClientProxy iClientProxy, string method, object arg1, CancellationToken cancellationToken = default) // { // return ClientProxyExtensions.SendAsync(iClientProxy, method, arg1, cancellationToken); // } //} //public interface IStaticWrapper //{ // Task SendAsync(IClientProxy iClientProxy, string method, object arg1, CancellationToken cancellationToken = default); //} //public class WrapperMethod //{ // readonly IStaticWrapper _wrapper; // public WrapperMethod(IStaticWrapper wrapper) // { // _wrapper = wrapper; // } // public Task SendAsync(IClientProxy iClientProxy, string method, object arg1, CancellationToken cancellationToken = default) // { // var value = _wrapper.SendAsync(iClientProxy, method, arg1, cancellationToken); // return value; // } //} //private class TestWrapper : IStaticWrapper //{ // public Task SendAsync(IClientProxy iClientProxy, string method, object arg1, CancellationToken cancellationToken = default) // { // realisation???; // } //} //[Fact] public async void AddTask_WhenTaskWithTwoParameters_ReturnsCorrectTasks() { var createdAt = DateTime.UtcNow; var mockTaskRequest = new AddTaskRequest { Title = "Test", Content = "Test task", }; var mockTaskFullRequest = new AddTaskFullRequest { Title = "Test", Content = "Test task", CreatedAt = createdAt }; var mockTaskResponse = new TaskGetResponse { TaskId = 1, Title = "Test", Content = "Test task", CreatedAt = createdAt, IsDone = false }; var mockDataRepository = new Mock <IDataRepository>(); mockDataRepository .Setup(repo => repo.AddTask(It.IsAny <AddTaskFullRequest>())) .Returns(() => Task.FromResult(It.IsAny <TaskGetResponse>())); var mockClientProxy = new Mock <IClientProxy>(); var mockHubContext = new Mock <IHubContext <TasksHub> >(); mockHubContext .Setup(hub => hub.Clients.Group(It.IsAny <string>()).SendAsync(It.IsAny <string>(), It.IsAny <Task <TaskGetResponse> >(), It.IsAny <CancellationToken>())) .Returns(It.IsAny <Task>()); var tasksController = new TasksController( mockDataRepository.Object, mockHubContext.Object, null, null); var result = await tasksController.AddTask(mockTaskRequest); var actionResult = Assert.IsType < ActionResult <TaskGetResponse> >(result); var taskResult = Assert.IsType <TaskGetResponse>(actionResult.Value); Assert.Equal(mockTaskResponse, taskResult); }
public void AddTaskTest() { // Arrange var controller = new TasksController(); Tasks tasks = new Tasks { Task1 = "Test Tasks" }; // Act IHttpActionResult actionResult = controller.AddTask(tasks); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <Tasks>; // Assert Assert.IsNotNull(createdResult); Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.IsNotNull(createdResult.RouteValues["id"]); }
public void AddTaskTest_Success() { // Arrange ProjectMangerModel.Tasks model = new ProjectMangerModel.Tasks { TaskID = 5, Task = "Task 5", ProjectID = 1, Priority = 10, StartDate = DateTime.Now.Date, EndDate = DateTime.Now.Date.AddDays(1) }; // Act var response = taskController.AddTask(model); // Assert Assert.IsTrue(response is OkResult); }
public void AddTaskTest_Error() { // Arrange var taskController = new TasksController(null); ProjectMangerModel.Tasks model = new ProjectMangerModel.Tasks { TaskID = 5, Task = "Task 5", ProjectID = 1, Priority = 10, StartDate = DateTime.Now.Date, EndDate = DateTime.Now.Date.AddDays(1) }; // Act var response = taskController.AddTask(model); // Assert Assert.IsTrue(response is InternalServerErrorResult); }