/// <summary> /// Uses the helper library to execute a search by display/external id. /// </summary> static void UseLibrary() { // Declare variables for our vault connection. Vault vault; MFilesServerApplication application; // The default connection (localhost, tcp, current Windows user) will suffice. var connectionDetails = new ConnectionDetails(); // Connect to the vault. connectionDetails.ConnectToVaultAdministrative( Program.sampleVaultGuid, out vault, out application); // Create the basic search conditions collection. var searchConditions = new SearchConditions(); // Add a condition for the display Id. searchConditions.AddDisplayIdSearchCondition(Program.customerDisplayId); // Search. var results = vault.ObjectSearchOperations.SearchForObjectsByConditions(searchConditions, MFSearchFlags.MFSearchFlagNone, SortResults: false); // Output the number of items matching (should be one in each object type, at a maximum). Console.WriteLine($"There were {results.Count} objects with the display Id of {Program.customerDisplayId}:"); Console.WriteLine($"Complete."); // Ensure we're disconnected. application.Disconnect(vault); }
public void AddDisplayIdSearchCondition_CountAtOne() { // Arrange. var searchConditions = new SearchConditions(); // Act. searchConditions.AddDisplayIdSearchCondition("hello"); // Assert. Assert.AreEqual(1, searchConditions.Count); }
public void AddDisplayIdSearchCondition_ConditionCorrect() { // Arrange. var searchConditions = new SearchConditions(); // Act. searchConditions.AddDisplayIdSearchCondition("hello"); // Assert. var condition = searchConditions[1]; Assert.IsNotNull(condition); Assert.AreEqual(MFConditionType.MFConditionTypeEqual, condition.ConditionType); Assert.AreEqual(MFStatusType.MFStatusTypeExtID, condition.Expression.DataStatusValueType); Assert.AreEqual(MFDataType.MFDatatypeText, condition.TypedValue.DataType); Assert.AreEqual("hello", condition.TypedValue.DisplayValue); }