public static VersionNumber ComputeNewVersion(bool hasApproving, VersioningType versioningMode) { if (!hasApproving) { switch (versioningMode) { case VersioningType.None: return(new VersionNumber(1, 0, VersionStatus.Approved)); case VersioningType.MajorOnly: return(new VersionNumber(1, 0, VersionStatus.Approved)); case VersioningType.MajorAndMinor: return(new VersionNumber(0, 1, VersionStatus.Draft)); } } else { switch (versioningMode) { case VersioningType.None: return(new VersionNumber(1, 0, VersionStatus.Pending)); case VersioningType.MajorOnly: return(new VersionNumber(1, 0, VersionStatus.Pending)); case VersioningType.MajorAndMinor: return(new VersionNumber(0, 1, VersionStatus.Draft)); } } throw new SnNotSupportedException(); }
private File CreateFile(VersioningType versioningType = VersioningType.Inherited, ApprovingType approvingType = ApprovingType.False) { var parent = (RepositoryTools.CreateStructure("/Root/Content/Docs", "DocumentLibrary") ?? Content.Load("/Root/Content/Docs")).ContentHandler; var file = new File(parent) { VersioningMode = versioningType, ApprovingMode = approvingType }; file.Save(); return(file); }
public override void SetProperty(string name, object value) { switch (name) { case VERSIONINGMODE: VersioningMode = (VersioningType)value; break; case ABORTONRELATEDCONTENTCHANGE: AbortOnRelatedContentChange = (bool)value; break; default: base.SetProperty(name, value); break; } }
private static void CreatingTest(bool hasApproving, VersioningType mode, string expectedVersion) { var gc = CreateNodeInMemory(hasApproving ? ApprovingType.True : ApprovingType.False, mode); var action = SavingAction.Create(gc); action.CheckOutAndSave(); Assert.IsTrue(action.CurrentVersion == null, "action.CurrentVersion is not null"); Assert.IsTrue(action.CurrentVersionId == 0, String.Concat("action.CurrentVersionId is ", action.CurrentVersionId, ". Expected: 0")); Assert.IsTrue(action.ExpectedVersion != null, "action.ExpectedVersion is null"); Assert.IsTrue(action.ExpectedVersion.ToString() == expectedVersion, String.Concat("action.CurrentVersion is ", action.ExpectedVersion, ". Expected: ", expectedVersion)); Assert.IsTrue(action.ExpectedVersionId == 0, String.Concat("action.ExpectedVersionId is ", action.ExpectedVersionId, ". Expected: 0")); Assert.IsTrue(action.LockerUserId == null, "action.LockerUserId not null"); Assert.IsTrue(action.DeletableVersionIds.Count == 0, String.Concat("action..DeletableVersions.Count is ", action.DeletableVersionIds.Count, ". Expected: 0")); }
private static void CreatingTest(bool hasApproving, VersioningType mode, string expectedVersion) { var gc = CreateNodeInMemory(hasApproving ? ApprovingType.True : ApprovingType.False, mode); var action = SavingAction.Create(gc); action.CheckOutAndSave(); Assert.IsTrue(action.CurrentVersion == null, "action.CurrentVersion is not null"); Assert.IsTrue(action.CurrentVersionId == 0, $"action.CurrentVersionId is {action.CurrentVersionId}. Expected: 0"); Assert.IsTrue(action.ExpectedVersion != null, "action.ExpectedVersion is null"); Assert.IsTrue(action.ExpectedVersion.ToString() == expectedVersion, $"action.CurrentVersion is {action.ExpectedVersion}. Expected: {expectedVersion}."); Assert.IsTrue(action.ExpectedVersionId == 0, $"action.ExpectedVersionId is ", action.ExpectedVersionId, ". Expected: 0"); Assert.IsTrue(action.LockerUserId == null, "action.LockerUserId not null"); Assert.IsTrue(action.DeletableVersionIds.Count == 0, $"action..DeletableVersions.Count is {action.DeletableVersionIds.Count}. Expected: 0"); }
public override void SetProperty(string name, object value) { switch (name) { case VERSIONINGMODE: VersioningMode = (VersioningType)value; break; case ABORTONRELATEDCONTENTCHANGE: AbortOnRelatedContentChange = (bool)value; break; case DELETEINSTANCEAFTERFINISHED: DeleteInstanceAfterFinished = (WorkflowDeletionStrategy)value; break; default: base.SetProperty(name, value); break; } }
public async Task Test_Versioning(VersioningType versioningType, ApprovingType approvingType, Func <File, Task> action, string expectedEventLog, string subscribedEvents = null) { File file = null; await Test_WebHook(() => { file = CreateFile(versioningType, approvingType); return(Task.CompletedTask); }, async() => { await action(file); return(file); }, (result, client, subscription) => { var eventLog = string.Join(",", client.Requests.Select(r => r.EventName)); Assert.AreEqual(expectedEventLog, eventLog); }, subscribedEvents); }
public static void UseAcceptHeaderApiVersion(String paramName) { CurrentVersioningMethod = VersioningType.AcceptHeader; AcceptHeaderParam = paramName; }
public static void UseQueryStringApiVersion(string parameterName) { CurrentVersioningMethod = VersioningType.QueryString; QueryStringParam = parameterName; }
public static void UseQueryStringApiVersion() { QueryStringParam = "api-version"; CurrentVersioningMethod = VersioningType.QueryString; }
public static void UseCustomHeaderApiVersion(string parameterName) { CurrentVersioningMethod = VersioningType.CustomHeader; CustomHeaderParam = parameterName; }
private static GenericContent CreateNodeInMemory(ApprovingType approvingType, VersioningType versioningType) { var content = Content.CreateNew("SystemFolder", Repository.Root, "SystemFolder1"); var gc = (GenericContent)content.ContentHandler; gc.ApprovingMode = approvingType; gc.VersioningMode = versioningType; return(gc); }
private static GenericContent CreateNodeInMemory(ApprovingType approvingType, VersioningType versioningType) { // do not save the content in this test // do not change the parent to TestRoot var content = Content.CreateNew("Car", Repository.Root, "car"); var gc = content.ContentHandler as GenericContent; gc.ApprovingMode = approvingType; gc.VersioningMode = versioningType; return(gc); }
public static VersionNumber ComputeNewVersion(bool hasApproving, VersioningType versioningMode) { if (!hasApproving) { switch (versioningMode) { case VersioningType.None: return new VersionNumber(1, 0, VersionStatus.Approved); case VersioningType.MajorOnly: return new VersionNumber(1, 0, VersionStatus.Approved); case VersioningType.MajorAndMinor: return new VersionNumber(0, 1, VersionStatus.Draft); } } else { switch (versioningMode) { case VersioningType.None: return new VersionNumber(1, 0, VersionStatus.Pending); case VersioningType.MajorOnly: return new VersionNumber(1, 0, VersionStatus.Pending); case VersioningType.MajorAndMinor: return new VersionNumber(0, 1, VersionStatus.Draft); } } throw new NotImplementedException(); }
private static GenericContent CreateNodeInMemory(ApprovingType approvingType, VersioningType versioningType) { // do not save the content in this test // do not change the parent to TestRoot var content = Content.CreateNew("Car", Repository.Root, "car"); var gc = content.ContentHandler as GenericContent; gc.ApprovingMode = approvingType; gc.VersioningMode = versioningType; return gc; }