public static void FormLink() { var mod = new SkyrimMod(Utility.LightMasterModKey, SkyrimRelease.SkyrimLE); var light = mod.Lights.AddNew(); var cache = mod.ToImmutableLinkCache(); var link = new FormLink <ISkyrimMajorRecordGetter>(light.FormKey); var nullableLink = new FormLinkNullable <ISkyrimMajorRecordGetter>(light.FormKey); IFormLink <ISkyrimMajorRecordGetter> iLink = link; // Normal resolution link.TryResolve(cache, out var _); link.TryResolve(cache, out ISkyrimMajorRecordGetter _); link.Resolve(cache); link.TryResolve <ILightGetter>(cache, out var _); link.TryResolve(cache, out ILightGetter _); link.Resolve <ILightGetter>(cache); nullableLink.TryResolve(cache, out var _); nullableLink.TryResolve(cache, out ISkyrimMajorRecordGetter _); nullableLink.Resolve(cache); nullableLink.TryResolve <ILightGetter>(cache, out var _); nullableLink.TryResolve(cache, out ILightGetter _); nullableLink.Resolve <ILightGetter>(cache); iLink.TryResolve(cache, out var _); iLink.Resolve(cache); iLink.TryResolve <ISkyrimMajorRecordGetter, ILightGetter>(cache, out var _); iLink.TryResolve(cache, out ILightGetter _); iLink.Resolve <ISkyrimMajorRecordGetter, ILightGetter>(cache); // Context resolution // ToDo // Enable when generic querying is supported //link.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out var _); //link.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out IModContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); //link.ResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache); link.TryResolveContext <ISkyrimMod, ILight, ILightGetter>(cache, out var _); link.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _); link.ResolveContext <ISkyrimMod, ILight, ILightGetter>(cache); //nullableLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out var _); //nullableLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out IModContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); //nullableLink.ResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache); nullableLink.TryResolveContext <ISkyrimMod, ILight, ILightGetter>(cache, out var _); nullableLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _); nullableLink.ResolveContext <ISkyrimMod, ILight, ILightGetter>(cache); //iLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); //iLink.ResolveContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); iLink.TryResolveContext <ISkyrimMod, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); iLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _); iLink.ResolveContext <ISkyrimMod, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); }
public void FormLink_Direct_Resolve_NoLink(LinkCacheTestTypes cacheType) { var formLink = new FormLink <INpcGetter>(UnusedFormKey); var(style, package) = GetLinkCache(new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE), cacheType); Assert.Null(formLink.TryResolve(package)); }
public void FormLink_Direct_Resolve_MarkerInterface_DeepRecord_Linked(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var worldspace = mod.Worldspaces.AddNew(); var subBlock = new WorldspaceSubBlock(); var cell = new Cell(mod.GetNextFormKey(), SkyrimRelease.SkyrimLE); subBlock.Items.Add(cell); var placedNpc = new PlacedNpc(mod.GetNextFormKey(), SkyrimRelease.SkyrimLE); cell.Temporary.Add(placedNpc); var block = new WorldspaceBlock(); block.Items.Add(subBlock); worldspace.SubCells.Add(block); var(style, package) = GetLinkCache(mod, cacheType); var placedFormLink = new FormLink <IPlacedGetter>(placedNpc.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.Same(placedNpc, placedFormLink.TryResolve(package)); }); var cellFormLink = new FormLink <ICellGetter>(cell.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.Same(cell, cellFormLink.TryResolve(package)); }); var worldspaceFormLink = new FormLink <IWorldspaceGetter>(worldspace.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.Same(worldspace, worldspaceFormLink.TryResolve(package)); }); }
public void FormLink_Direct_TryResolve_DeepRecord_NoLink(LinkCacheTestTypes cacheType) { var formLink = new FormLink <IPlacedNpcGetter>(UnusedFormKey); var(style, package) = GetLinkCache(new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE), cacheType); Assert.False(formLink.TryResolve(package, out var _)); }
public void FormLink_LoadOrder_TryResolve_DeepRecord_NoLink() { var package = TypicalLoadOrder().ToImmutableLinkCache(); FormLink <IPlacedNpc> formLink = new FormLink <IPlacedNpc>(UnusedFormKey); Assert.False(formLink.TryResolve(package, out var _)); }
public void FormLink_LoadOrder_Resolve_MarkerInterface_DeepRecord_NoLink() { FormLink <IPlaced> formLink = new FormLink <IPlaced>(UnusedFormKey); var package = TypicalLoadOrder().ToImmutableLinkCache(); Assert.Null(formLink.TryResolve(package)); }
public void FormLink_LoadOrder_TryResolve_MarkerInterface_NoLink() { FormLink <IEffectRecord> formLink = new FormLink <IEffectRecord>(UnusedFormKey); var package = TypicalLoadOrder().ToImmutableLinkCache(); Assert.False(formLink.TryResolve(package, out var _)); }
public void FormLink_LoadOrder_Resolve_NoLink() { var package = TypicalLoadOrder().ToImmutableLinkCache(); FormLink <INpc> formLink = new FormLink <INpc>(UnusedFormKey); Assert.Null(formLink.TryResolve(package)); }
public void FormLink_Direct_Resolve_MarkerInterface(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var spell = mod.Spells.AddNew(); var(style, package) = GetLinkCache(mod, cacheType); var formLink = new FormLink <IEffectRecordGetter>(spell.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.Same(spell, formLink.TryResolve(package)); }); }
public void FormLink_Direct_Resolve_Linked(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var npc = mod.Npcs.AddNew(); var(style, package) = GetLinkCache(mod, cacheType); FormLink <INpc> formLink = new FormLink <INpc>(npc.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.Same(npc, formLink.TryResolve(package)); }); }
public void FormLink_LoadOrder_TryResolve_DeepRecord_Linked(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var worldspace = mod.Worldspaces.AddNew(); var subBlock = new WorldspaceSubBlock(); var cell = new Cell(mod.GetNextFormKey(), SkyrimRelease.SkyrimLE); subBlock.Items.Add(cell); var placedNpc = new PlacedNpc(mod.GetNextFormKey(), SkyrimRelease.SkyrimLE); cell.Temporary.Add(placedNpc); var block = new WorldspaceBlock(); block.Items.Add(subBlock); worldspace.SubCells.Add(block); var loadOrder = new LoadOrder <ISkyrimModGetter>() { mod, new SkyrimMod(TestConstants.PluginModKey2, SkyrimRelease.SkyrimLE), }; var(style, package) = GetLinkCache(loadOrder, cacheType); FormLink <IPlacedNpc> placedFormLink = new FormLink <IPlacedNpc>(placedNpc.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.True(placedFormLink.TryResolve(package, out var linkedPlacedNpc)); Assert.Same(placedNpc, linkedPlacedNpc); }); FormLink <ICell> cellFormLink = new FormLink <ICell>(cell.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.True(cellFormLink.TryResolve(package, out var linkedCell)); Assert.Same(cell, linkedCell); }); FormLink <IWorldspace> worldspaceFormLink = new FormLink <IWorldspace>(worldspace.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.True(worldspaceFormLink.TryResolve(package, out var linkedWorldspace)); Assert.Same(worldspace, linkedWorldspace); }); }
public void FormLink_LoadOrder_TryResolve_Linked(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var npc = mod.Npcs.AddNew(); var loadOrder = new LoadOrder <ISkyrimModGetter>() { mod, new SkyrimMod(TestConstants.PluginModKey2, SkyrimRelease.SkyrimLE), }; var(style, package) = GetLinkCache(loadOrder, cacheType); FormLink <INpc> formLink = new FormLink <INpc>(npc.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.True(formLink.TryResolve(package, out var linkedRec)); Assert.Same(npc, linkedRec); }); }
public void FormLink_LoadOrder_TryResolve_MarkerInterface(LinkCacheTestTypes cacheType) { var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE); var spell = mod.Spells.AddNew(); var loadOrder = new LoadOrder <ISkyrimModGetter>() { mod, new SkyrimMod(TestConstants.PluginModKey2, SkyrimRelease.SkyrimLE), }; var(style, package) = GetLinkCache(loadOrder, cacheType); FormLink <IEffectRecord> formLink = new FormLink <IEffectRecord>(spell.FormKey); WrapPotentialThrow(cacheType, style, () => { Assert.True(formLink.TryResolve(package, out var linkedRec)); Assert.Same(spell, linkedRec); }); }
public static void FormLink() { var mod = new SkyrimMod(Utility.LightMasterModKey, SkyrimRelease.SkyrimLE); var light = mod.Lights.AddNew(); var cache = mod.ToImmutableLinkCache(); var link = new FormLink <ISkyrimMajorRecordGetter>(light.FormKey); var nullableLink = new FormLinkNullable <ISkyrimMajorRecordGetter>(light.FormKey); IFormLinkGetter <ISkyrimMajorRecordGetter> iLink = link; // Normal resolution link.TryResolve(cache, out var _); link.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _); link.Resolve(cache); link.TryResolve <ILightGetter>(cache, out var _); link.TryResolve(cache, out ILightGetter _); link.Resolve <ILightGetter>(cache); nullableLink.TryResolve(cache, out var _); nullableLink.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _); nullableLink.Resolve(cache); nullableLink.TryResolve <ILightGetter>(cache, out var _); nullableLink.TryResolve(cache, out ILightGetter _); nullableLink.Resolve <ILightGetter>(cache); iLink.TryResolve(cache, out var _); iLink.Resolve(cache); iLink.TryResolve <ISkyrimMajorRecordGetter, ILightGetter>(cache, out var _); iLink.TryResolve(cache, out ILightGetter _); iLink.Resolve <ISkyrimMajorRecordGetter, ILightGetter>(cache); // Context resolution link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); link.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _); nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); nullableLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _); iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache); iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _); iLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _); iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache); // Getter interface conversion IPerkGetter getter = new Perk(Utility.Form1, SkyrimRelease.SkyrimLE); Perk direct = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE); IPerk setter = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE); IFormLink <IPerkGetter> formLink = new FormLink <IPerkGetter>(); formLink = getter.AsLink(); formLink = direct.AsLink(); formLink = setter.AsLink(); formLink.SetTo(direct); formLink.SetTo(getter); formLink.SetTo(setter); formLink.SetTo(formLink); IObjectEffectGetter objGetter = null !; IFormLink <IEffectRecordGetter> aLink = new FormLink <IEffectRecordGetter>(); aLink.SetTo(objGetter); IFormLink <ISkyrimMajorRecordGetter> majRecordLink = new FormLink <ISkyrimMajorRecordGetter>(); IFormLink <IKeywordGetter> keywordLink = new FormLink <IKeywordGetter>(); majRecordLink.SetTo(keywordLink); majRecordLink.TryResolve <IKeywordGetter>(cache, out var keyw); }