Beispiel #1
0
        public void TestEditProjectCommandWithInvalidId()
        {
            // Arrange
            bool isFaulted = false;

            var project = new ProjectPutModel
            {
                Name        = ProjectNameConst,
                Description = ProjectDescriptionConst
            };

            var projectsEditCommand = new ProjectsEditCommand(GetFakeApiController(), GetFakeProjectRepository(), GetFakeQueueVideoRepository(), ProjectInvalidIdConst, project);

            // Act
            Task <HttpResponseMessage> responseTask = projectsEditCommand.Execute();
            Task <bool> result = responseTask.ContinueWith(p => isFaulted = p.IsFaulted, TaskContinuationOptions.ExecuteSynchronously);

            result.Wait();

            // Assert
            Assert.IsFalse(isFaulted);
            Assert.IsNotNull(responseTask.Result);
            Assert.AreEqual(responseTask.Result.StatusCode, HttpStatusCode.NotFound);
            _repositoryMock.Verify(m => m.EditAsync(It.IsAny <ProjectEditParameters>()), Times.Once());
            Assert.AreEqual(UserIdConst, _userId);
            Assert.AreEqual(_projectName, ProjectNameConst);
            Assert.AreEqual(_projectDescription, ProjectDescriptionConst);
            Assert.AreEqual(_projectId, ProjectInvalidIdConst);
        }
Beispiel #2
0
        public void TestEditProjectCommand()
        {
            // Arrange
            var project = new ProjectPutModel
            {
                Name        = ProjectNameConst,
                Description = ProjectDescriptionConst,
                Data        = DataNameConst,
                DataUri     = DataUriConst,
                Video       = VideoNameConst,
                VideoUri    = VideoUriConst
            };

            var projectsEditCommand = new ProjectsEditCommand(GetFakeApiController(), GetFakeProjectRepository(), GetFakeQueueVideoRepository(), ProjectIdConst, project);

            // Act
            Task <HttpResponseMessage> responseTask = projectsEditCommand.Execute();

            responseTask.Wait();

            HttpResponseMessage response = responseTask.Result;

            // Assert
            _repositoryMock.Verify(m => m.EditAsync(It.IsAny <ProjectEditParameters>()), Times.Once());
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(UserIdConst, _userId);
            Assert.AreEqual(_projectName, ProjectNameConst);
            Assert.AreEqual(_projectDescription, ProjectDescriptionConst);
            Assert.AreEqual(_projectId, ProjectIdConst);
            Assert.AreEqual(_videoName, VideoNameConst);
            Assert.AreEqual(_videoUri, VideoUriConst);
            Assert.AreEqual(_dataName, DataNameConst);
            Assert.AreEqual(_dataUri, DataUriConst);
            Assert.IsNull(_isPublicValue);
        }
        public void TestEditProjectCommandWithInvalidId()
        {
            // Arrange
            bool isFaulted = false;

            var project = new ProjectPutModel
                {
                    Name = ProjectNameConst,
                    Description = ProjectDescriptionConst
                };

            var projectsEditCommand = new ProjectsEditCommand(GetFakeApiController(), GetFakeProjectRepository(), GetFakeQueueVideoRepository(), ProjectInvalidIdConst, project);

            // Act
            Task<HttpResponseMessage> responseTask = projectsEditCommand.Execute();
            Task<bool> result = responseTask.ContinueWith(p => isFaulted = p.IsFaulted, TaskContinuationOptions.ExecuteSynchronously);
            result.Wait();

            // Assert
            Assert.IsFalse(isFaulted);
            Assert.IsNotNull(responseTask.Result);
            Assert.AreEqual(responseTask.Result.StatusCode, HttpStatusCode.NotFound);
            _repositoryMock.Verify(m => m.EditAsync(It.IsAny<ProjectEditParameters>()), Times.Once());
            Assert.AreEqual(UserIdConst, _userId);
            Assert.AreEqual(_projectName, ProjectNameConst);
            Assert.AreEqual(_projectDescription, ProjectDescriptionConst);
            Assert.AreEqual(_projectId, ProjectInvalidIdConst);
        }
        public void TestEditProjectCommand()
        {
            // Arrange
            var project = new ProjectPutModel
                {
                    Name = ProjectNameConst,
                    Description = ProjectDescriptionConst,
                    Data = DataNameConst,
                    DataUri = DataUriConst,
                    Video = VideoNameConst,
                    VideoUri = VideoUriConst
                };

            var projectsEditCommand = new ProjectsEditCommand(GetFakeApiController(), GetFakeProjectRepository(), GetFakeQueueVideoRepository(), ProjectIdConst, project);

            // Act
            Task<HttpResponseMessage> responseTask = projectsEditCommand.Execute();
            responseTask.Wait();

            HttpResponseMessage response = responseTask.Result;

            // Assert
            _repositoryMock.Verify(m => m.EditAsync(It.IsAny<ProjectEditParameters>()), Times.Once());
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(UserIdConst, _userId);
            Assert.AreEqual(_projectName, ProjectNameConst);
            Assert.AreEqual(_projectDescription, ProjectDescriptionConst);
            Assert.AreEqual(_projectId, ProjectIdConst);
            Assert.AreEqual(_videoName, VideoNameConst);
            Assert.AreEqual(_videoUri, VideoUriConst);
            Assert.AreEqual(_dataName, DataNameConst);
            Assert.AreEqual(_dataUri, DataUriConst);
            Assert.IsNull(_isPublicValue);
        }