|
|
|
@ -25,88 +25,17 @@ public class CustomFormatStepTest
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase("name1", 0)]
|
|
|
|
|
[TestCase("naME1", 0)]
|
|
|
|
|
[TestCase("DifferentName", 1)]
|
|
|
|
|
public void Match_cf_in_guide_with_different_name_with_cache_using_same_name_in_config(string variableCfName,
|
|
|
|
|
int outdatedCount)
|
|
|
|
|
{
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testCache = new CustomFormatCache
|
|
|
|
|
{
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping>
|
|
|
|
|
{
|
|
|
|
|
new("id1", "name1")
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testGuideData = new List<CustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Data(variableCfName, "id1")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var processor = new CustomFormatStep();
|
|
|
|
|
processor.Process(testGuideData, testConfig, testCache);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().HaveCount(outdatedCount);
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Processed(variableCfName, "id1", testCache.TrashIdMappings[0])
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Cache_entry_is_not_set_when_id_is_different(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
|
var guideData = new List<CustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Data("name1", "id1")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testCache = new CustomFormatCache
|
|
|
|
|
{
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping>
|
|
|
|
|
{
|
|
|
|
|
new("id1000", "name1")
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, testCache);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Count.Should().Be(1);
|
|
|
|
|
processor.ProcessedCustomFormats.Should()
|
|
|
|
|
.BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Processed("name1", "id1")
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Cfs_not_in_config_are_skipped(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
|
var ctx = new Context();
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1", "name3"}}
|
|
|
|
|
new() {TrashIds = new List<string> {"id1", "id3"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(ctx.TestGuideData, testConfig, new CustomFormatCache());
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should()
|
|
|
|
|
.BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
@ -122,14 +51,12 @@ public class CustomFormatStepTest
|
|
|
|
|
var ctx = new Context();
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1", "name3"}},
|
|
|
|
|
new() {Names = new List<string> {"name2"}}
|
|
|
|
|
new() {TrashIds = new List<string> {"id1", "id3"}},
|
|
|
|
|
new() {TrashIds = new List<string> {"id2"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(ctx.TestGuideData, testConfig, new CustomFormatCache());
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
@ -150,20 +77,18 @@ public class CustomFormatStepTest
|
|
|
|
|
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1"}}
|
|
|
|
|
new() {TrashIds = new List<string> {"id1"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testCache = new CustomFormatCache
|
|
|
|
|
{
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping> {new("id1000", "name1")}
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping> {new("id1000")}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, testCache);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should()
|
|
|
|
|
.BeEquivalentTo(new[] {new TrashIdMapping("id1000", "name1")});
|
|
|
|
|
.BeEquivalentTo(new[] {new TrashIdMapping("id1000")});
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Processed("name1", "id1")
|
|
|
|
@ -175,7 +100,7 @@ public class CustomFormatStepTest
|
|
|
|
|
{
|
|
|
|
|
var cache = new CustomFormatCache
|
|
|
|
|
{
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping> {new("id1", "3D", 9)}
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping> {new("id1", 9)}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var guideCfs = new List<CustomFormatData>
|
|
|
|
@ -185,90 +110,10 @@ public class CustomFormatStepTest
|
|
|
|
|
|
|
|
|
|
processor.Process(guideCfs, Array.Empty<CustomFormatConfig>(), cache);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEquivalentTo(new[] {cache.TrashIdMappings[0]});
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Custom_format_name_in_cache_is_updated_if_renamed_in_guide_and_config(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
|
var guideData = new List<CustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Data("name2", "id1")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name2"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testCache = new CustomFormatCache
|
|
|
|
|
{
|
|
|
|
|
TrashIdMappings = new Collection<TrashIdMapping> {new("id1", "name1")}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, testCache);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should()
|
|
|
|
|
.ContainSingle().Which.CacheEntry.Should()
|
|
|
|
|
.BeEquivalentTo(new TrashIdMapping("id1", "name2"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Duplicates_are_recorded_and_removed_from_processed_custom_formats_list(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
|
var guideData = new List<CustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Data("name1", "id1"),
|
|
|
|
|
NewCf.Data("name1", "id2")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, null);
|
|
|
|
|
|
|
|
|
|
//Dictionary<string, List<ProcessedCustomFormatData>>
|
|
|
|
|
processor.DuplicatedCustomFormats.Should()
|
|
|
|
|
.ContainKey("name1").WhoseValue.Should()
|
|
|
|
|
.BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Processed("name1", "id1"),
|
|
|
|
|
NewCf.Processed("name1", "id2")
|
|
|
|
|
});
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Match_cf_names_regardless_of_case_in_config(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
|
var ctx = new Context();
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"name1", "NAME1"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(ctx.TestGuideData, testConfig, new CustomFormatCache());
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|
{
|
|
|
|
|
NewCf.Processed("name1", "id1")
|
|
|
|
|
},
|
|
|
|
|
op => op.Using(new JsonEquivalencyStep()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test, AutoMockData]
|
|
|
|
|
public void Match_custom_format_using_trash_id(CustomFormatStep processor)
|
|
|
|
|
{
|
|
|
|
@ -285,8 +130,6 @@ public class CustomFormatStepTest
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, null);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should()
|
|
|
|
|
.BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
@ -301,13 +144,11 @@ public class CustomFormatStepTest
|
|
|
|
|
var ctx = new Context();
|
|
|
|
|
var testConfig = new List<CustomFormatConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Names = new List<string> {"doesnt_exist"}}
|
|
|
|
|
new() {TrashIds = new List<string> {"doesnt_exist"}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.Process(ctx.TestGuideData, testConfig, new CustomFormatCache());
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should().BeEmpty();
|
|
|
|
|
}
|
|
|
|
@ -324,7 +165,7 @@ public class CustomFormatStepTest
|
|
|
|
|
{
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
Names = new List<string> {"name1"},
|
|
|
|
|
TrashIds = new List<string> {"id1"},
|
|
|
|
|
QualityProfiles = new List<QualityProfileConfig>
|
|
|
|
|
{
|
|
|
|
|
new() {Name = "profile", Score = 200}
|
|
|
|
@ -334,8 +175,6 @@ public class CustomFormatStepTest
|
|
|
|
|
|
|
|
|
|
processor.Process(guideData, testConfig, null);
|
|
|
|
|
|
|
|
|
|
processor.DuplicatedCustomFormats.Should().BeEmpty();
|
|
|
|
|
processor.CustomFormatsWithOutdatedNames.Should().BeEmpty();
|
|
|
|
|
processor.DeletedCustomFormatsInCache.Should().BeEmpty();
|
|
|
|
|
processor.ProcessedCustomFormats.Should()
|
|
|
|
|
.BeEquivalentTo(new List<ProcessedCustomFormatData>
|
|
|
|
|