You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.9 KiB
54 lines
1.9 KiB
// Author: Gockner, Simon
|
|
// Created: 2020-03-09
|
|
// Copyright(c) 2020 SimonG. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using GBase;
|
|
using GBase.Factories;
|
|
using GBase.FileHandling.Factories;
|
|
using GBase.Interfaces;
|
|
using GBase.Interfaces.DataHandling.Pool;
|
|
using GBase.Interfaces.FileHandling;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Test.GBase.TestClasses;
|
|
|
|
namespace Test.GBase
|
|
{
|
|
[TestFixture]
|
|
public class GBaseTableIntegrationTest
|
|
{
|
|
[Test]
|
|
public void TestEntryHandling()
|
|
{
|
|
Mock<IFileHandlerFactory> fileHandlerFactoryMock = new Mock<IFileHandlerFactory>();
|
|
fileHandlerFactoryMock.Setup(f => f.Create()).Returns(new Mock<IFileHandler>().Object);
|
|
|
|
IGBaseColumn gBaseColumn = null;
|
|
Mock<IGBaseColumnFactory> gBaseColumnFactoryMock = new Mock<IGBaseColumnFactory>();
|
|
gBaseColumnFactoryMock.Setup(c => c.Create(It.IsAny<string>(), It.IsAny<Type>()))
|
|
.Callback<string, Type>((name, type) => { gBaseColumn = new GBaseColumn(name, type); })
|
|
.Returns(gBaseColumn);
|
|
|
|
Mock<IDataHandlerPool> dataHandlerPoolMock = new Mock<IDataHandlerPool>();
|
|
|
|
IGBaseTable<Foo> table = new GBaseTable<Foo>(fileHandlerFactoryMock.Object, dataHandlerPoolMock.Object, gBaseColumnFactoryMock.Object);
|
|
table.Init(typeof(Foo), "", "", CancellationToken.None);
|
|
|
|
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
Foo foo = new Foo("Test");
|
|
table.AddEntry(foo, cancellationTokenSource.Token);
|
|
|
|
Foo foo2 = new Foo("Test2");
|
|
table.AddEntry(foo2, cancellationTokenSource.Token);
|
|
|
|
foo.Name = "Foo - ex Test";
|
|
foo2.Name = "Some Name";
|
|
|
|
Assert.AreEqual(foo.Name, ((Foo) table.Entries[0]).Name);
|
|
Assert.AreEqual(foo2.Name, ((Foo) table.Entries[1]).Name);
|
|
}
|
|
}
|
|
} |