public async Task LocateFromPath_JustRoot() { var rootGroup = new Group("ABPaint".ToCharArray()); await ABSRegistry.AddItemToRootAsync(rootGroup); Assert.AreEqual(rootGroup, await ABSRegistry.LocateFromPathAsync("/ABPaint")); }
public async Task SplitPath_Nothing_EmptyPath() { var expected = new List <List <char> >(); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync("")); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync(new char[0])); }
public async Task GetItems_MultipleParts() { var inner = new Group("Inner".ToCharArray()) { InnerItems = new List <Item>() { new Group("Final1".ToCharArray()), new Group("Final2".ToCharArray()), } }; var rootArr = new Group[] { new Group("Test1".ToCharArray()) { InnerItems = new List <Item>() { inner } }, new Group("Test2".ToCharArray()), new Group("Test3".ToCharArray()) }; for (int i = 0; i < rootArr.Length; i++) { await ABSRegistry.AddItemToRootAsync(rootArr[i]); } CollectionAssert.AreEqual(inner.InnerItems, await ABSRegistry.GetItemsAsync("Test1/Inner")); CollectionAssert.AreEqual(inner.InnerItems, await ABSRegistry.GetItemsAsync("/Test1/Inner")); }
public async Task Delete_ItemWithInnerItems() { var rootArr = new Group[] { new Group("Test1".ToCharArray()) { InnerItems = new List <Item>() { new Group("Inner".ToCharArray()) } }, new Group("Test2".ToCharArray()), new Group("Test3".ToCharArray()) }; for (int i = 0; i < rootArr.Length; i++) { await ABSRegistry.AddItemToRootAsync(rootArr[i]); } // Delete the item. await ABSRegistry.DeleteAsync("Test1"); // It shouldn't exist anymore. Assert.IsFalse(await ABSRegistry.ExistsAsync("Test1")); Assert.IsFalse(await ABSRegistry.ExistsAsync("Test1/Inner")); }
public BaseViewModel() { var allProperties = typeof(T).GetProperties(); PropertyChanged += (s, e) => UpdateRegistry(e.PropertyName); for (int i = 0; i < allProperties.Length; i++) { var attribute = allProperties[i].GetCustomAttribute <RegistrySyncAttribute>(); if (attribute != null) { var regItem = ABSRegistry.GetItem(attribute.RegistryPath); if (regItem is RegGroup) { ABSLog.ThrowError("Cannot registry sync to a group."); } var syncInfo = new RegistrySyncInfo(allProperties[i], regItem, attribute.BooleanGroupPos); _registrySyncProperties.Add(allProperties[i].Name, syncInfo); AddEventHandlerToItem(syncInfo, regItem); UpdateProperty(syncInfo); } } }
public unsafe void GetSegment_Invalid() { char *ch = stackalloc char[4]; Assert.IsFalse(ABSRegistry.GetSegment("$AG:", ch, out _, out _)); Assert.IsFalse(ABSRegistry.GetSegment("XYZ:", ch, out _, out _)); Assert.IsFalse(ABSRegistry.GetSegment("abc", ch, out _, out _)); }
public async Task SplitPath_RootOnly_EmptyPath() { var expected = new List <List <char> >(); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync("/")); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync(new char[] { '/' })); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync("\\")); CollectionAssert.AreEqual(expected, await ABSRegistry.SplitPathAsync(new char[] { '\\' })); }
public async Task CreateGroup_AddToRoot() { var groupName = "Test"; // Add the group. await ABSRegistry.CreateGroupAsync(groupName); // Make sure that group exists. CollectionAssert.AreEqual(groupName.ToCharArray(), ABSRegistry.RegistryItems[0].Name); }
public async Task AddItemAt_AddToRoot() { var groupName = "Test".ToCharArray(); // Add the item. await ABSRegistry.AddItemAtAsync("", new Group(groupName)); // Make sure that group exists. CollectionAssert.AreEqual(groupName, ABSRegistry.RegistryItems[0].Name); }
public async Task LocateInGroup_ValidPath() { var group = new Group("ABPaint".ToCharArray()); group.InnerItems = new List <Item>() { new Group("Another".ToCharArray()) }; CollectionAssert.AreEqual((await ABSRegistry.LocateInGroupAsync("Another", group)).Name, "Another".ToCharArray()); }
public async Task LocateInGroup_InvalidPath() { var group = new Group("ABPaint".ToCharArray()) { InnerItems = new List <Item>() { new Group("Another".ToCharArray()) } }; Assert.AreEqual(await ABSRegistry.LocateInGroupAsync("Another2", group), null); }
public async Task Exists_InRoot_DoesExist() { // Set up the registry. await ABSRegistry.AddItemToRootAsync(new Group("Test1".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test2".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test3".ToCharArray())); Assert.IsTrue(await ABSRegistry.ExistsAsync("Test1")); Assert.IsTrue(await ABSRegistry.ExistsAsync("/Test1")); }
public unsafe void GetSegment_Alias_Valid() { var newSegment = new RegSegment(); ABSRegistry.SegmentAliases.Add("abc", newSegment); char *ch = stackalloc char[4]; Assert.IsTrue(ABSRegistry.GetSegment("$abc:", ch, out int pos, out RegSegment segment)); Assert.AreEqual(newSegment, segment); Assert.AreEqual(5, pos); }
public async Task LocateFromPath_MultipleParts() { var secondGroup = new Group("Another".ToCharArray()); var rootGroup = new Group("ABPaint".ToCharArray()) { InnerItems = new List <Item>() { secondGroup } }; await ABSRegistry.AddItemToRootAsync(rootGroup); CollectionAssert.AreEqual(secondGroup.Name, (await ABSRegistry.LocateFromPathAsync("/ABPaint/Another")).Name); }
public async Task SplitPath_GroupInRoot() { var expected = new List <List <char> >() { new List <char>() { 'A', 'B', 'P', 'a', 'i', 'n', 't' } }; Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("ABPaint"))); Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("/ABPaint"))); Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("\\ABPaint"))); }
public async Task AddItemAt_InOtherGroup_NotGroup() { var groupName = "NewGroup".ToCharArray(); // Set up the registry. await ABSRegistry.AddItemToRootAsync(new Group("Test1".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test2".ToCharArray())); // Add the item. await ABSRegistry.AddItemAtAsync("Test1", new Group(groupName)); // Make sure that group exists. CollectionAssert.AreEqual(groupName, (ABSRegistry.RegistryItems[0] as Group).InnerItems[0].Name); }
public async Task Delete_InRoot() { // Set up the registry. await ABSRegistry.AddItemToRootAsync(new Group("Test1".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test2".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test3".ToCharArray())); // Delete the item. await ABSRegistry.DeleteAsync("Test2"); // It shouldn't exist anymore. Assert.IsFalse(await ABSRegistry.ExistsAsync("Test2")); }
public async Task CreateGroup_InOtherGroup() { // Set up the registry. await ABSRegistry.AddItemToRootAsync(new Group("Test1".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test2".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test3".ToCharArray())); // Add the group. await ABSRegistry.CreateGroupAsync("Test1/NewGroup"); // Make sure that group exists. CollectionAssert.AreEqual("NewGroup".ToCharArray(), (ABSRegistry.RegistryItems[0] as Group).InnerItems[0].Name); }
public async Task GetItems_FromRoot() { var rootArr = new Group[] { new Group("Test1".ToCharArray()), new Group("Test2".ToCharArray()), new Group("Test3".ToCharArray()) }; for (int i = 0; i < rootArr.Length; i++) { await ABSRegistry.AddItemToRootAsync(rootArr[i]); } CollectionAssert.AreEqual(rootArr, await ABSRegistry.GetItemsAsync("/")); }
public async Task AddItemToRoot_AlreadyExists() { var groupName = "Test".ToCharArray(); // Add the group. await ABSRegistry.AddItemToRootAsync(new Group(groupName)); try { await ABSRegistry.AddItemToRootAsync(new Group(groupName)); // An exception should have been thrown, so it shouldn't get here. Assert.Fail(); } catch (Exception) { } }
public async Task AddItemAt_InOtherGroup_AlreadyExists() { // Set up the registry. await ABSRegistry.AddItemToRootAsync(new Group("Test1".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test2".ToCharArray())); await ABSRegistry.AddItemToRootAsync(new Group("Test3".ToCharArray())); // Add the item. await ABSRegistry.AddItemAtAsync("Test1", new Group("NewGroup".ToCharArray())); try { await ABSRegistry.AddItemAtAsync("Test1", new Group("NewGroup".ToCharArray())); // An exception should have been thrown. Assert.Fail(); } catch (Exception) { } }
public async Task GetItems_InvalidPath() { var rootArr = new Group[] { new Group("Test1".ToCharArray()), new Group("Test2".ToCharArray()), new Group("Test3".ToCharArray()) }; for (int i = 0; i < rootArr.Length; i++) { await ABSRegistry.AddItemToRootAsync(rootArr[i]); } try { // This should throw an exception, meaning the "Assert.Fail" never gets hit. await ABSRegistry.GetItemsAsync("Test4"); Assert.Fail(); } catch (Exception) { } }
public async Task SplitPath_MultipleParts() { var expected = new List <List <char> >() { new List <char>() { 'A', 'B', 'P', 'a', 'i', 'n', 't' }, new List <char>() { 'N', 'e', 'x', 't' }, new List <char>() { 'A', 'n', 'o', 't', 'h', 'e', 'r' } }; Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("ABPaint/Next/Another"))); Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("/ABPaint/Next/Another"))); Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("ABPaint\\Next\\Another"))); Assert.IsTrue(TestArr(expected, await ABSRegistry.SplitPathAsync("\\ABPaint\\Next\\Another"))); }
public async Task Exists_MultipleParts_DoesExist() { var rootArr = new Group[] { new Group("Test1".ToCharArray()) { InnerItems = new List <Item>() { new Group("Inner".ToCharArray()) } }, new Group("Test2".ToCharArray()), new Group("Test3".ToCharArray()) }; for (int i = 0; i < rootArr.Length; i++) { await ABSRegistry.AddItemToRootAsync(rootArr[i]); } Assert.IsTrue(await ABSRegistry.ExistsAsync("Test1/Inner")); Assert.IsTrue(await ABSRegistry.ExistsAsync("/Test1/Inner")); }
public async Task Exists_RootItself_DoesExist() { Assert.IsTrue(await ABSRegistry.ExistsAsync("/")); }
public async Task LocateInRoot_ValidPath() { await ABSRegistry.AddItemToRootAsync(new Group("ABPaint".ToCharArray())); CollectionAssert.AreEqual((await ABSRegistry.LocateInRootAsync("ABPaint")).Name, "ABPaint".ToCharArray()); }
public async Task Exists_InRoot_DoesNotExist() { Assert.IsFalse(await ABSRegistry.ExistsAsync("Test1")); Assert.IsFalse(await ABSRegistry.ExistsAsync("/Test1")); }
public void Init() => ABSRegistry.ClearRegistry();
public async Task Exists_MultipleParts_DoesNotExist() { Assert.IsFalse(await ABSRegistry.ExistsAsync("Test1/Another")); Assert.IsFalse(await ABSRegistry.ExistsAsync("/Test1/Another")); }
public async Task LocateInRoot_InvalidPath() { Assert.AreEqual(await ABSRegistry.LocateInRootAsync("(None)"), null); }