Exemplo n.º 1
0
        public ApiCollectionModel(MainWindowModel mainWindow, ApiCollectionModel parent, ApiCollection apiCollection)
            : base(mainWindow, parent, apiCollection)
        {
            Model = apiCollection;

            if (apiCollection.Items != null)
                Items.AddRange(apiCollection.Items.Select(x => x.Type == ApiItemType.Collection ?
                    (ApiItemModel)new ApiCollectionModel(mainWindow, this, (ApiCollection)x) :
                    new ApiModel(mainWindow, this, (Api)x)));

            Items.SetUpSync(
                MainWindow.Repository,
                Model.Items,
                x => x.ItemModel);
        }
Exemplo n.º 2
0
        public async Task InsertMinimalApiCollection()
        {
            var collection = new ApiCollection
            {
                Title = "test title",
                Type = ApiItemType.Collection,
                Created = new DateTime(2015, 1, 1)
            };
            await repository.AddItem(collection);

            Assert.AreNotEqual(0, collection.Id);

            var dbApiItem = await db.ApiItems.SingleAsync(x => x.Id == collection.Id);
            Assert.AreEqual(collection.Title, dbApiItem.Title);
            Assert.AreEqual(collection.Type, dbApiItem.Type);
            Assert.AreEqual(collection.Created, dbApiItem.Created);
        }
Exemplo n.º 3
0
        public async Task CreateThreeLevelHierarchy()
        {
            var rootCollection = new ApiCollection { Items = new RxList<ApiItem>(), Title = "Root" };
            await repository.AddItem(rootCollection);
            await repository.WaitForIdle();

            var childCollection = new ApiCollection { Items = new RxList<ApiItem>(), Title = "Child" };
            rootCollection.Items.Add(childCollection);
            await repository.WaitForIdle();

            var leaf = new Api { Title = "Leaf" };
            childCollection.Items.Add(leaf);
            await repository.WaitForIdle();

            var newRepository = new DbRepository(db);
            await newRepository.Load();

            var loadedRootCollection = (ApiCollection)newRepository.Items.Single();
            Assert.AreEqual(rootCollection.Title, loadedRootCollection.Title);

            var loadedChildCollection = (ApiCollection)loadedRootCollection.Items.Single();
            Assert.AreEqual(childCollection.Title, loadedChildCollection.Title);

            var loadedLeaf = (Api)loadedChildCollection.Items.Single();
            Assert.AreEqual(leaf.Title, loadedLeaf.Title);
        }
Exemplo n.º 4
0
        public async Task UpdateCollectionAddApiChild()
        {
            var collection = new ApiCollection
            {
                Items = new RxList<ApiItem>()
            };
            await repository.AddItem(collection);

            collection.Items.Add(new Api());

            await repository.WaitForIdle();

            var dbApiItem = await db.ApiItems.Include(x => x.Items).SingleAsync(x => x.Id == collection.Id);
            Assert.AreEqual(1, dbApiItem.Items.Count);
        }
Exemplo n.º 5
0
 public static ApiCollectionModel Import(MainWindowModel mainWindow, ApiCollectionModel parent, ApiCollection apiCollection)
 {
     return new ApiCollectionModel(mainWindow, parent, apiCollection);
 }