From 2e2c0f74c2aded10796f40e9726b8040eaf8fc8a Mon Sep 17 00:00:00 2001 From: Simon G Date: Fri, 18 Sep 2020 15:09:24 +0200 Subject: [PATCH] - start adding complete GBase integration --- Test.GBase/GBaseIntegrationTest/Group.cs | 21 +++++++++ Test.GBase/GBaseIntegrationTest/IGroup.cs | 14 ++++++ Test.GBase/GBaseIntegrationTest/IItem.cs | 13 ++++++ Test.GBase/GBaseIntegrationTest/Item.cs | 15 ++++++ Test.GBase/GBaseIntegrationTest/Model.cs | 51 +++++++++++++++++++++ Test.GBase/GBaseIntegrationTest/Settings.cs | 13 ++++++ 6 files changed, 127 insertions(+) create mode 100644 Test.GBase/GBaseIntegrationTest/Group.cs create mode 100644 Test.GBase/GBaseIntegrationTest/IGroup.cs create mode 100644 Test.GBase/GBaseIntegrationTest/IItem.cs create mode 100644 Test.GBase/GBaseIntegrationTest/Item.cs create mode 100644 Test.GBase/GBaseIntegrationTest/Model.cs create mode 100644 Test.GBase/GBaseIntegrationTest/Settings.cs diff --git a/Test.GBase/GBaseIntegrationTest/Group.cs b/Test.GBase/GBaseIntegrationTest/Group.cs new file mode 100644 index 0000000..d1dc03c --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/Group.cs @@ -0,0 +1,21 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using GBase.Api; +using GBase.Attributes; + +namespace Test.GBase.GBaseIntegrationTest +{ + [GBaseTable] + public class Group : NotifyGBaseEntryChanged, IGroup + { + public Group() + { + Items = new List(); + } + + public List Items { get; } + } +} \ No newline at end of file diff --git a/Test.GBase/GBaseIntegrationTest/IGroup.cs b/Test.GBase/GBaseIntegrationTest/IGroup.cs new file mode 100644 index 0000000..966eac8 --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/IGroup.cs @@ -0,0 +1,14 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using GBase.Api; + +namespace Test.GBase.GBaseIntegrationTest +{ + public interface IGroup : INotifyGBaseEntryChanged + { + List Items { get; } + } +} \ No newline at end of file diff --git a/Test.GBase/GBaseIntegrationTest/IItem.cs b/Test.GBase/GBaseIntegrationTest/IItem.cs new file mode 100644 index 0000000..5d4fe77 --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/IItem.cs @@ -0,0 +1,13 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using GBase.Api; + +namespace Test.GBase.GBaseIntegrationTest +{ + public interface IItem : INotifyGBaseEntryChanged + { + + } +} \ No newline at end of file diff --git a/Test.GBase/GBaseIntegrationTest/Item.cs b/Test.GBase/GBaseIntegrationTest/Item.cs new file mode 100644 index 0000000..e1f32b0 --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/Item.cs @@ -0,0 +1,15 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using GBase.Api; +using GBase.Attributes; + +namespace Test.GBase.GBaseIntegrationTest +{ + [GBaseTable] + public class Item : NotifyGBaseEntryChanged, IItem + { + + } +} \ No newline at end of file diff --git a/Test.GBase/GBaseIntegrationTest/Model.cs b/Test.GBase/GBaseIntegrationTest/Model.cs new file mode 100644 index 0000000..8253bc1 --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/Model.cs @@ -0,0 +1,51 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using GBase.Factories; +using GBase.Interfaces; + +namespace Test.GBase.GBaseIntegrationTest +{ + public class Model + { + private readonly IGBase _gBase; + + public Model(IGBaseFactory gBaseFactory) + { + _gBase = gBaseFactory.Create(new Settings()); + Items = new List(); + Groups = new List(); + } + + public List Items { get; private set; } + public List Groups { get; private set; } + + public async Task Initialize(CancellationToken cancellationToken) + { + await _gBase.Init("DB", Assembly.GetExecutingAssembly(), cancellationToken); + + IGBaseTable itemsTable = _gBase.GetTable(); + Items = itemsTable.Entries; + + IGBaseTable groupsTable = _gBase.GetTable(); + Groups = groupsTable.Entries; + } + + public void AddItem(IItem item) + { + Items.Add(item); + _gBase.AddEntry(item); + } + + public void AddGroup(IGroup group) + { + Groups.Add(group); + _gBase.AddEntry(@group); + } + } +} \ No newline at end of file diff --git a/Test.GBase/GBaseIntegrationTest/Settings.cs b/Test.GBase/GBaseIntegrationTest/Settings.cs new file mode 100644 index 0000000..8335033 --- /dev/null +++ b/Test.GBase/GBaseIntegrationTest/Settings.cs @@ -0,0 +1,13 @@ +// Author: Gockner, Simon +// Created: 2020-09-18 +// Copyright(c) 2020 SimonG. All Rights Reserved. + +using GBase.Interfaces.Settings; + +namespace Test.GBase.GBaseIntegrationTest +{ + public class Settings : IGBaseSettings + { + public string DatabasePath => ""; + } +} \ No newline at end of file