diff options
| author | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
|---|---|---|
| committer | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
| commit | 7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch) | |
| tree | 27fb39be241fdb5ac2734c574de678977d1856d0 /libs/bsapacker/tests/ArchiveNameServiceFacts.cpp | |
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem,
Proton/umu-run integration, and Flatpak packaging.
Key features:
- FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak)
- Proton/GE-Proton/umu-run launcher with env var forwarding
- Flatpak support (sandbox-aware VFS, NXM handler, umu-run)
- Wine prefix management UI
- Case-insensitive path resolution for Linux filesystems
- QSettings-safe INI handling (avoids Bethesda INI corruption)
- Portable instance support with auto-generated launcher scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/bsapacker/tests/ArchiveNameServiceFacts.cpp')
| -rw-r--r-- | libs/bsapacker/tests/ArchiveNameServiceFacts.cpp | 260 |
1 files changed, 260 insertions, 0 deletions
diff --git a/libs/bsapacker/tests/ArchiveNameServiceFacts.cpp b/libs/bsapacker/tests/ArchiveNameServiceFacts.cpp new file mode 100644 index 0000000..c79c545 --- /dev/null +++ b/libs/bsapacker/tests/ArchiveNameServiceFacts.cpp @@ -0,0 +1,260 @@ +#include "gtest/gtest.h" +#include "gmock/gmock.h" + +#include "ArchiveNameService.h" +#include "MockModContext.h" +#include "ModDto.h" +#include "NexusId.h" + +using namespace BsaPacker; +using ::testing::NaggyMock; +using ::testing::Eq; +using ::testing::Return; + +namespace BsaPackerTests +{ + class ArchiveNameServiceFacts : public ::testing::Test + { + protected: + void SetUp() override { + naggyMockModContext = new NaggyMock<MockModContext>(); + } + + void TearDown() override { + delete naggyMockModContext; + } + + NaggyMock<MockModContext>* naggyMockModContext; + }; + + TEST_F(ArchiveNameServiceFacts, Ctor_Always_Constructs) + { + EXPECT_NO_THROW( + auto result = ArchiveNameService( + naggyMockModContext + ); + ); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsMorrowind_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Morrowind)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsOblivion_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Oblivion)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsFallout3_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Fallout3)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsNewVegas_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::NewVegas)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsSkyrim_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Skyrim)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsSkyrimSE_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::SkyrimSE)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_WhenNexusIdIsFallout4_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Fallout4)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ(".ba2", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetFileExtension_InvalidNexusId_Returnsbsa) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(0)); + + // Act + auto result = sut.GetFileExtension(); + + // Assert + EXPECT_EQ("", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaFO4_ReturnsFullPathWithMainInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baFO4; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Fallout4)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive - Main.ba2", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaFO4dds_ReturnsFullPathWithTextureInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baFO4dds; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Fallout4)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive - Textures.ba2", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaTES3_ReturnsFullPathWithoutInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baTES3; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Morrowind)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive.bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaTES4_ReturnsFullPathWithoutInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baTES3; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Oblivion)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive.bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaFO3_ReturnsFullPathWithoutInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baFO3; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::Fallout3)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive.bsa", result.toStdString()); + } + + TEST_F(ArchiveNameServiceFacts, GetArchiveFullPath_WhenTypeIsbaSSE_ReturnsFullPathWithoutInfix) + { + // Arrange + auto sut = ArchiveNameService( + naggyMockModContext); + auto type = bsa_archive_type_e::baSSE; + auto dto = ModDto(0, "C:/directory", "archive", ".ba2"); + ON_CALL(*naggyMockModContext, GetNexusId()) + .WillByDefault(Return(NexusId::SkyrimSE)); + + // Act + auto result = sut.GetArchiveFullPath(type, &dto); + + // Assert + EXPECT_EQ("C:/directory/archive.bsa", result.toStdString()); + } +} |
