Пример #1
0
        public void WhenProjectIsSavedThenItShouldBePersisted()
        {
            // Arrange
            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();

            var project = new Project
            {
                Name          = "Test Project " + Guid.NewGuid(),
                Description   = "Test Project Description",
                UserId        = userId,
                ApplicationId = applicationId,
                DateCreated   = DateTime.Now,
                DateModified  = DateTime.Now
            };

            // Act
            using (var unitOfWork = new UnitOfWork(_context))
            {
                unitOfWork.Projects.Add(project);
                unitOfWork.Complete();
            }

            // Assert
            Assert.IsTrue(project.Id > 0);
        }
Пример #2
0
        public void WhenQueryApplicationShouldReturnRelatedProjects()
        {
            // Arrange
            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();

            TestInitializeUtils.CreateTestProject(applicationId, userId);
            TestInitializeUtils.CreateTestProject(applicationId, userId);
            int projectCount;

            // Act
            using (var unitOfWork = new UnitOfWork(_context))
            {
                var applications = unitOfWork.Applications.GetApplicationAndReleatedProjects(applicationId);
                projectCount = applications.Projects.ToList().Count;
            }

            // Assert
            Assert.AreEqual(2, projectCount);
        }
Пример #3
0
        public void WhenInValidUserThenProjectCountShouldBeZero()
        {
            // Arrange
            int projectCount;

            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();

            TestInitializeUtils.CreateTestProject(applicationId, userId);

            // Act
            using (var unitOfWork = new UnitOfWork(_context))
            {
                const int invalidUserId = -1;
                var       projects      = unitOfWork.Projects.GetProjectsForUser(invalidUserId);
                projectCount = projects.ToList().Count;
            }

            // Assert
            Assert.AreEqual(0, projectCount);
        }
Пример #4
0
        public void WhenProjectHasImageThenGetProjectImageShouldBeNotNull()
        {
            // Arrange
            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();
            var imageFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images",
                                             "TestProjectImage.png");
            var imageOctets = ReadImageAsOctectString(imageFilename);
            var projectId   = TestInitializeUtils.CreateTestProject(applicationId, userId, imageOctets);

            // Act
            byte[] imageAsByteArray;
            using (var unitOfWork = new UnitOfWork(_context))
            {
                imageAsByteArray = unitOfWork.Projects.GetProjectImage(projectId);
            }

            // Assert
            Assert.IsNotNull(imageAsByteArray);
            Assert.IsTrue(imageAsByteArray.Length > 0);
        }
Пример #5
0
        public void WhenValidProjectThenScenarioCountShouldBeGreaterThanZero()
        {
            // Arrange
            int scenarioCount;

            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();
            var projectId     = TestInitializeUtils.CreateTestProject(applicationId, userId);

            TestInitializeUtils.CreateTestScenario(projectId);
            TestInitializeUtils.CreateTestScenario(projectId);

            // Act
            using (var unitOfWork = new UnitOfWork(_context))
            {
                var scenarios = unitOfWork.Scenarios.GetScenariosForProject(projectId);
                scenarioCount = scenarios.ToList().Count;
            }

            // Assert
            Assert.AreEqual(2, scenarioCount);
        }
Пример #6
0
        public void WhenValidUserThenProjectsAndRelatedScenariosShouldBeGreaterThanZero()
        {
            // Arrange
            int scenarioCount;

            var userId        = TestInitializeUtils.CreateTestUser();
            var applicationId = TestInitializeUtils.CreateTestApplication();
            var projectId     = TestInitializeUtils.CreateTestProject(applicationId, userId);

            TestInitializeUtils.CreateTestScenario(projectId);
            TestInitializeUtils.CreateTestScenario(projectId);

            // Act
            using (var unitOfWork = new UnitOfWork(_context))
            {
                var projects = unitOfWork.Projects.GetProjectsAndReleatedScenariosForUser(userId);
                var project  = projects.First();

                scenarioCount = project.Scenarios.Count;
            }

            // Assert
            Assert.AreEqual(2, scenarioCount);
        }