コード例 #1
0
        GivenWorkshopItemChangeSetWithoutDescriptionFilePath__WhenCallingGetDescriptionTextFromFile__ShouldReturnEmptyString()
        {
            string                expectedDescriptionText = string.Empty;
            MockFileSystem        fileSystem = new MockFileSystem();
            WorkshopItemChangeSet sut        = new WorkshopItemChangeSet(fileSystem);

            string actual = sut.GetDescriptionTextFromFile();

            Assert.AreEqual(expectedDescriptionText, actual);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        GivenWorkshopItemChangeSetWithDescriptionFilePath__WhenCallingGetDescriptionTextFromFile__ShouldReturnDescriptionText()
        {
            const string   expectedDescriptionText = "The description";
            MockFileSystem fileSystem = new MockFileSystem();

            fileSystem.AddFile("path/to/description", new MockFileData(expectedDescriptionText));
            WorkshopItemChangeSet sut = new WorkshopItemChangeSet(fileSystem)
            {
                DescriptionFilePath = "path/to/description"
            };

            string actual = sut.GetDescriptionTextFromFile();

            Assert.AreEqual(expectedDescriptionText, actual);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public async Task GivenWorkshopChangeSet__WhenPublishingToSteam__ItemShouldBeOnWorkshop()
        {
            WorkshopItemChangeSet changeSet = new WorkshopItemChangeSet(_fileSystem)
            {
                Title = Title,
                DescriptionFilePath = DescriptionFilePath,
                Language            = Language,
                Visibility          = WorkshopItemVisibility.Private,
                ItemFolderPath      = SteamUploadPath
            };

            _sut.Init(32470);
            WorkshopItemPublishResult publishTaskResult = await _sut.PublishNewWorkshopItemAsync(changeSet);

            PublishResult publishResult = publishTaskResult.Result;

            Assert.AreEqual(PublishResult.Ok, publishResult);
            await AssertItemMatchesSettings(publishTaskResult);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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));
        }