public void TestGetProjectCommandByInvalidId() { // Arrange Task <Project> getTask = null; AggregateException exception = null; var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), ProjectInvalidIdConst); // Act try { getTask = projectsGetCommand.Execute(); getTask.Wait(); } catch (AggregateException e) { exception = e; } // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny <ProjectGetParameters>()), Times.Once()); Assert.IsNotNull(getTask); Assert.IsTrue(getTask.IsFaulted); Assert.AreEqual(_userId, UserIdConst); Assert.IsNotNull(exception); Assert.AreEqual(((HttpResponseException)exception.InnerException).Response.StatusCode, HttpStatusCode.NotFound); Assert.AreEqual(ProjectInvalidIdConst, _projectId); }
public void TestGetProjectCommandByEmptyId() { // Arrange const string id = ""; Task <Project> getTask = null; AggregateException exception = null; var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), id); // Act try { getTask = projectsGetCommand.Execute(); getTask.Wait(); } catch (AggregateException e) { exception = e; } // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny <ProjectGetParameters>()), Times.Never()); Assert.IsNotNull(getTask); Assert.IsTrue(getTask.IsFaulted); Assert.IsNotNull(exception); Assert.AreEqual(((HttpResponseException)exception.InnerException).Response.StatusCode, HttpStatusCode.BadRequest); }
public void TestGetProjectCommand() { // Arrange var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), ProjectIdConst); // Act Task <Project> getTask = projectsGetCommand.Execute(); getTask.Wait(); // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny <ProjectGetParameters>()), Times.Once()); Assert.IsFalse(getTask.IsFaulted); Assert.IsNotNull(getTask.Result); Assert.AreEqual(UserIdConst, _userId); Assert.AreEqual(ProjectIdConst, getTask.Result.Id); Assert.AreEqual(ProjectIdConst, _projectId); }
public void TestGetProjectCommandByInvalidId() { // Arrange Task<Project> getTask = null; AggregateException exception = null; var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), ProjectInvalidIdConst); // Act try { getTask = projectsGetCommand.Execute(); getTask.Wait(); } catch (AggregateException e) { exception = e; } // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny<ProjectGetParameters>()), Times.Once()); Assert.IsNotNull(getTask); Assert.IsTrue(getTask.IsFaulted); Assert.AreEqual(_userId, UserIdConst); Assert.IsNotNull(exception); Assert.AreEqual(((HttpResponseException) exception.InnerException).Response.StatusCode, HttpStatusCode.NotFound); Assert.AreEqual(ProjectInvalidIdConst, _projectId); }
public void TestGetProjectCommandByEmptyId() { // Arrange const string id = ""; Task<Project> getTask = null; AggregateException exception = null; var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), id); // Act try { getTask = projectsGetCommand.Execute(); getTask.Wait(); } catch (AggregateException e) { exception = e; } // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny<ProjectGetParameters>()), Times.Never()); Assert.IsNotNull(getTask); Assert.IsTrue(getTask.IsFaulted); Assert.IsNotNull(exception); Assert.AreEqual(((HttpResponseException) exception.InnerException).Response.StatusCode, HttpStatusCode.BadRequest); }
public void TestGetProjectCommand() { // Arrange var projectsGetCommand = new ProjectsGetCommand(GetFakeApiController(), GetFakeProjectRepository(), ProjectIdConst); // Act Task<Project> getTask = projectsGetCommand.Execute(); getTask.Wait(); // Assert _repositoryMock.Verify(m => m.GetAsync(It.IsAny<ProjectGetParameters>()), Times.Once()); Assert.IsFalse(getTask.IsFaulted); Assert.IsNotNull(getTask.Result); Assert.AreEqual(UserIdConst, _userId); Assert.AreEqual(ProjectIdConst, getTask.Result.Id); Assert.AreEqual(ProjectIdConst, _projectId); }