private ModActionEnum DoCheck(int repoHash, int repoVersion, int?storageHash, int?storageVersion, StorageModStateEnum state, bool canWrite = true) { // TODO: restructure a bit for less parameter passing all over the place var repoMod = new MockModelRepositoryMod(repoHash, repoVersion); var storageMod = new MockModelStorageMod(storageHash, storageVersion, state) { CanWrite = canWrite }; return(CoreCalculation.GetModAction(repoMod, storageMod)); }
internal static ModAction Create(ModSelection selection, IModelRepositoryMod parent) { return(selection switch { ModSelectionNone => new SelectNone(), ModSelectionLoading => new SelectLoading(), ModSelectionDisabled => new SelectDisabled(), ModSelectionDownload download => new SelectStorage(download.DownloadStorage), ModSelectionStorageMod actionStorageMod => new SelectMod(actionStorageMod.StorageMod, CoreCalculation.GetModAction(parent, actionStorageMod.StorageMod)), _ => throw new ArgumentException() });
internal static IModelStorageMod FromAction(ModActionEnum actionType, bool canWrite = true) { var storageMod = actionType switch { ModActionEnum.Update => new MockModelStorageMod(1, 2, StorageModStateEnum.Created), ModActionEnum.ContinueUpdate => new MockModelStorageMod(1, 1, StorageModStateEnum.CreatedWithUpdateTarget), ModActionEnum.Await => new MockModelStorageMod(1, 1, StorageModStateEnum.Updating), ModActionEnum.Use => new MockModelStorageMod(1, 1, StorageModStateEnum.Created), ModActionEnum.AbortAndUpdate => new MockModelStorageMod(1, 2, StorageModStateEnum.CreatedWithUpdateTarget), ModActionEnum.AbortActiveAndUpdate => new MockModelStorageMod(1, 2, StorageModStateEnum.Updating), ModActionEnum.Unusable => new MockModelStorageMod(2, 2, StorageModStateEnum.Created), _ => throw new ArgumentOutOfRangeException(nameof(actionType), actionType, null) }; storageMod.CanWrite = canWrite; // just checking that we got the setup right var testRepoMod = new MockModelRepositoryMod(1, 1); Assert.Equal(actionType, CoreCalculation.GetModAction(testRepoMod, storageMod)); return(storageMod); }