using OF_DL.Models.Config; namespace OF_DL.Tests.Models.Config; public class ConfigTests { [Fact] public void GetCreatorFileNameFormatConfig_UsesCreatorFormatWhenDefined() { OF_DL.Models.Config.Config config = new() { PaidPostFileNameFormat = "global-paid-post", PostFileNameFormat = "global-post", PaidMessageFileNameFormat = "global-paid-message", MessageFileNameFormat = "global-message", CreatorConfigs = new Dictionary { ["creator"] = new() { PaidPostFileNameFormat = "creator-paid-post", PostFileNameFormat = "creator-post", PaidMessageFileNameFormat = "creator-paid-message", MessageFileNameFormat = "creator-message" } } }; IFileNameFormatConfig result = config.GetCreatorFileNameFormatConfig("creator"); Assert.Equal("creator-paid-post", result.PaidPostFileNameFormat); Assert.Equal("creator-post", result.PostFileNameFormat); Assert.Equal("creator-paid-message", result.PaidMessageFileNameFormat); Assert.Equal("creator-message", result.MessageFileNameFormat); } [Fact] public void GetCreatorFileNameFormatConfig_FallsBackToGlobalWhenCreatorFormatIsNullOrEmpty() { OF_DL.Models.Config.Config config = new() { PaidPostFileNameFormat = "global-paid-post", PostFileNameFormat = "global-post", PaidMessageFileNameFormat = "global-paid-message", MessageFileNameFormat = "global-message", CreatorConfigs = new Dictionary { ["creator"] = new() { PaidPostFileNameFormat = null, PostFileNameFormat = "", PaidMessageFileNameFormat = null, MessageFileNameFormat = "" } } }; IFileNameFormatConfig result = config.GetCreatorFileNameFormatConfig("creator"); Assert.Equal("global-paid-post", result.PaidPostFileNameFormat); Assert.Equal("global-post", result.PostFileNameFormat); Assert.Equal("global-paid-message", result.PaidMessageFileNameFormat); Assert.Equal("global-message", result.MessageFileNameFormat); } [Fact] public void GetCreatorFileNameFormatConfig_UsesGlobalWhenCreatorConfigDoesNotExist() { OF_DL.Models.Config.Config config = new() { PaidPostFileNameFormat = "global-paid-post", PostFileNameFormat = "global-post", PaidMessageFileNameFormat = "global-paid-message", MessageFileNameFormat = "global-message", CreatorConfigs = new Dictionary { ["other-creator"] = new() { PaidPostFileNameFormat = "other-paid-post", PostFileNameFormat = "other-post", PaidMessageFileNameFormat = "other-paid-message", MessageFileNameFormat = "other-message" } } }; IFileNameFormatConfig result = config.GetCreatorFileNameFormatConfig("creator"); Assert.Equal("global-paid-post", result.PaidPostFileNameFormat); Assert.Equal("global-post", result.PostFileNameFormat); Assert.Equal("global-paid-message", result.PaidMessageFileNameFormat); Assert.Equal("global-message", result.MessageFileNameFormat); } [Fact] public void GetCreatorFileNameFormatConfig_ReturnsEmptyFormatsWhenCreatorAndGlobalAreUndefined() { OF_DL.Models.Config.Config config = new() { PaidPostFileNameFormat = "", PostFileNameFormat = "", PaidMessageFileNameFormat = "", MessageFileNameFormat = "", CreatorConfigs = new Dictionary { ["creator"] = new() { PaidPostFileNameFormat = "", PostFileNameFormat = null, PaidMessageFileNameFormat = "", MessageFileNameFormat = null } } }; IFileNameFormatConfig result = config.GetCreatorFileNameFormatConfig("creator"); Assert.True(string.IsNullOrEmpty(result.PaidPostFileNameFormat)); Assert.True(string.IsNullOrEmpty(result.PostFileNameFormat)); Assert.True(string.IsNullOrEmpty(result.PaidMessageFileNameFormat)); Assert.True(string.IsNullOrEmpty(result.MessageFileNameFormat)); } }