Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }