Esempio n. 1
0
        public void LoadProject_ReadProjectThrowsEntityReadException_ThrowsStorageException()
        {
            // Setup
            string tempProjectFilePath = Path.Combine(workingDirectory, nameof(LoadProject_ReadProjectThrowsEntityReadException_ThrowsStorageException));
            var    storage             = new StorageSqLite();

            RiskeerProject project = CreateProject();

            // Precondition
            void Precondition()
            {
                SqLiteDatabaseHelper.CreateValidProjectDatabase(tempProjectFilePath, project);
                SqLiteDatabaseHelper.SetInvalidNumberOfAssessmentSectionEntities(tempProjectFilePath);
            }

            Assert.DoesNotThrow(Precondition);

            // Call
            void Call() => storage.LoadProject(tempProjectFilePath);

            // Assert
            var       exception      = Assert.Throws <StorageException>(Call);
            Exception innerException = exception.InnerException;

            Assert.IsInstanceOf <EntityReadException>(innerException);

            var expectedMessage = $"Fout bij het lezen van bestand '{tempProjectFilePath}': {innerException.Message.FirstToLower()}";

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Esempio n. 2
0
        public void HasStagedProjectChanges_ValidProjectLoaded_ReturnsFalse()
        {
            // Setup
            var            storageSqLite       = new StorageSqLite();
            RiskeerProject storedProject       = CreateProject();
            string         tempProjectFilePath = Path.Combine(workingDirectory, nameof(HasStagedProjectChanges_ValidProjectLoaded_ReturnsFalse));

            SqLiteDatabaseHelper.CreateValidProjectDatabase(tempProjectFilePath, storedProject);
            IProject loadedProject = storageSqLite.LoadProject(tempProjectFilePath);

            storageSqLite.StageProject(loadedProject);

            // Call
            bool hasChanges = storageSqLite.HasStagedProjectChanges(tempProjectFilePath);

            // Assert
            Assert.IsFalse(hasChanges);
        }
Esempio n. 3
0
        public void HasStagedProjectChanges_ValidProjectLoadedWithAffectedChange_ReturnsTrue()
        {
            // Setup
            var            storageSqLite       = new StorageSqLite();
            RiskeerProject storedProject       = RiskeerProjectTestHelper.GetFullTestProject();
            const string   changedDescription  = "some description";
            string         tempProjectFilePath = Path.Combine(workingDirectory, nameof(HasStagedProjectChanges_ValidProjectLoadedWithAffectedChange_ReturnsTrue));

            SqLiteDatabaseHelper.CreateValidProjectDatabase(tempProjectFilePath, storedProject);
            IProject loadedProject = storageSqLite.LoadProject(tempProjectFilePath);

            loadedProject.Description = changedDescription;
            storageSqLite.StageProject(loadedProject);

            // Call
            bool hasChanges = storageSqLite.HasStagedProjectChanges(tempProjectFilePath);

            // Assert
            Assert.IsTrue(hasChanges);
        }
Esempio n. 4
0
        public void LoadProject_ValidDatabase_ReturnsProject()
        {
            // Setup
            string tempProjectFilePath = Path.Combine(workingDirectory, nameof(LoadProject_ValidDatabase_ReturnsProject));
            string projectName         = Path.GetFileNameWithoutExtension(tempProjectFilePath);
            var    storage             = new StorageSqLite();

            RiskeerProject project = CreateProject();

            project.Description = "<some description>";

            // Precondition
            SqLiteDatabaseHelper.CreateValidProjectDatabase(tempProjectFilePath, project);

            // Call
            IProject loadedProject = storage.LoadProject(tempProjectFilePath);

            // Assert
            Assert.IsInstanceOf <RiskeerProject>(loadedProject);
            Assert.AreEqual(projectName, loadedProject.Name);
            Assert.AreEqual(project.Description, loadedProject.Description);
        }