GivenWorkshopItemWithoutItemFolderPath__WhenCallingIsValid__ShouldReturnFalseAndInvalidOperationException()
        {
            MockFileSystem fileSystem = new MockFileSystem();

            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title = "Title"
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(InvalidOperationException));
            Assert.AreEqual("No item folder set", exception.Message);
        }
        GivenWorkshopItemChangeSetWithNonExistingItemFolder__WhenCallingIsValid__ShouldReturnFalseAndDirectoryNotFoundException()
        {
            MockFileSystem fileSystem = new MockFileSystem();

            const string          nonExistingFolder = "non/existing/folder";
            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title          = "Title",
                ItemFolderPath = nonExistingFolder
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(DirectoryNotFoundException));
        }
        GivenWorkshopItemChangeSetWithoutTitle__WhenCallingIsValid__ShouldReturnFalseAndInvalidOperationException()
        {
            MockFileSystem fileSystem     = new MockFileSystem();
            const string   itemFolderPath = "path/to/item/folder";

            fileSystem.AddDirectory(itemFolderPath);
            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                ItemFolderPath = itemFolderPath
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(InvalidOperationException));
            Assert.AreEqual("No title set", exception.Message);
        }
        GivenWorkshopItemChangeSetWithAbsoluteItemFolderPath__WhenCallingIsValid__ShouldReturnFalseAndNoRelativePathException()
        {
            const string   absolutePath = "/absolute/path";
            MockFileSystem fileSystem   = new MockFileSystem();

            fileSystem.AddDirectory(absolutePath);

            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title          = "Title",
                ItemFolderPath = absolutePath
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(NoRelativePathException));
        }
        GivenWorkshopItemChangeSetWithValidMinimalSettings__WhenCallingIsValid__ShouldReturnTrueAndNoException()
        {
            MockFileSystem fileSystem     = new MockFileSystem();
            const string   itemFolderPath = "path/to/item/folder";

            fileSystem.AddDirectory(itemFolderPath);

            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title          = "Title",
                ItemFolderPath = itemFolderPath
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsTrue(isValid);
            Assert.IsNull(exception);
        }
        GivenWorkshopItemChangeSetWithNonExistingDescriptionFile__WhenCallingIsValid__ShouldReturnFalseAndFileNotFoundException()
        {
            const string itemFolderPath      = "path/to/item/folder";
            const string descriptionFilePath = "non/existing/file";

            MockFileSystem fileSystem = new MockFileSystem();

            fileSystem.AddDirectory(itemFolderPath);
            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title               = "Title",
                ItemFolderPath      = itemFolderPath,
                DescriptionFilePath = descriptionFilePath
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(FileNotFoundException));
        }
        GivenWorkshopItemChangeSetWithAbsoluteDescriptionFilePath__WhenCallingIsValid__ShouldReturnFalseAndNoRelativePathException()
        {
            const string itemFolderPath      = "path/to/item/folder";
            const string descriptionFilePath = "/absolute/path/to/file";

            MockFileSystem fileSystem = new MockFileSystem();

            fileSystem.AddDirectory(itemFolderPath);
            fileSystem.AddFile(descriptionFilePath, MockFileData.NullObject);

            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                Title               = "Title",
                ItemFolderPath      = itemFolderPath,
                DescriptionFilePath = descriptionFilePath
            };

            (bool isValid, Exception exception) = sut.IsValidChangeSet();

            Assert.IsFalse(isValid);
            Assert.IsInstanceOfType(exception, typeof(NoRelativePathException));
        }