private void assertTypeContainer(cmisTypeContainer container, int depth) { Assert.IsNotNull(container, "container is null"); Assert.IsNotNull(container.type, "container.type is null"); if (depth == 0) { Assert.IsTrue((container.children == null || container.children.Length == 0), "descedants were returned for depth=" + (depth + 1) + ", but expected for depth=" + depth); } else if (container.children != null) { foreach (cmisTypeContainer childContainer in container.children) { if (childContainer != null && childContainer.type != null) { Assert.AreEqual(container.type.id, childContainer.type.parentId, "child type='" + childContainer.type.id + "' has parent type = '" + childContainer.type.parentId + ", but expected '" + container.type.id + "'"); } assertTypeContainer(childContainer, depth - 1); } } }
private void assertBaseTypes(cmisTypeContainer[] containers) { HashSet<string> types = new HashSet<string>(); foreach (cmisTypeContainer container in containers) { Assert.IsNotNull(container, "container is null"); Assert.IsNotNull(container.type, "container.type is null"); types.Add(container.type.id); } Assert.IsTrue(types.Contains(BASE_TYPE_DOCUMENT), "Base type '" + BASE_TYPE_DOCUMENT + "' is not found"); Assert.IsTrue(types.Contains(BASE_TYPE_FOLDER), "Base type '" + BASE_TYPE_FOLDER + "' is not found"); Assert.IsTrue(types.Contains(BASE_TYPE_RELATIONSHIP), "Base type '" + BASE_TYPE_RELATIONSHIP + "' is not found"); }
private static void assertTypeContainer(cmisTypeContainer container) { Assert.IsNotNull(container, "One of the Type Containers from Get Type Descendants response is solely in 'not set' state"); Assert.IsNotNull(container.type, "Undefined Type in one of Type Containers from Get Type Descendants response"); Assert.IsNotNull(container.type.id, "Undefined Type Id in one of Type Containers from Get Type Descendants response"); }
protected static string enumerateAndAssertTypesForAction(cmisTypeContainer[] rootContainers, TypeAction action, bool firstIsValid) { Queue<cmisTypeContainer> queue = new Queue<cmisTypeContainer>(rootContainers); string actionResult = null; while (queue.Count > 0) { cmisTypeContainer typeContainer = queue.Dequeue(); assertTypeContainer(typeContainer); string currentResult = action.perform(typeContainer.type); if (null != currentResult) { if (firstIsValid) { return currentResult; } else { actionResult = currentResult; } } if (null != typeContainer.children) { foreach (cmisTypeContainer container in typeContainer.children) { assertTypeContainer(container); queue.Enqueue(container); } } } return actionResult; }