Something went wrong on our end
Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
MetadataTests.cs 2.92 KiB
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Coscine.Configuration;
using Coscine.Metadata.Models;
using NUnit.Framework;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace Coscine.Metadata.Tests
{
[TestFixture]
public class MetadataTests
{
private readonly IConfiguration _configuration = new ConsulConfiguration();
private RdfStoreConnector _rdfStoreConnector;
private const string _testUriPrefix = "http://test.de";
//private string _shapeGraph = File.ReadAllText("Metadata.Tests/TestFiles/radar_shape.ttl");
//private string _dataGraph = File.ReadAllText("Metadata.Tests/TestFiles/radar_input.ttl");
private void RemoveTestGraphs()
{
foreach (var grapUri in _rdfStoreConnector.ListGraphs())
{
if (grapUri.ToString().StartsWith(_testUriPrefix))
{
_rdfStoreConnector.DeleteGraph(grapUri);
}
}
}
private void AddTestGraphs()
{
}
[OneTimeSetUp]
public void Init()
{
_rdfStoreConnector = new RdfStoreConnector(_configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
RemoveTestGraphs();
AddTestGraphs();
}
[OneTimeTearDown]
public void Cleanup()
{
RemoveTestGraphs();
}
[Test]
public void HasGraphTest()
{
Assert.IsTrue(_rdfStoreConnector.HasGraph("http://www.openlinksw.com/schemas/virtrdf#"));
Assert.IsTrue(_rdfStoreConnector.HasGraph("http://localhost:8890/DAV/"));
Assert.IsFalse(_rdfStoreConnector.HasGraph("https://test.de/fdgdhjklö/"));
}
[Test]
public void GetGraphTest()
{
Assert.IsFalse(_rdfStoreConnector.GetGraph("http://www.openlinksw.com/schemas/virtrdf#").IsEmpty);
Assert.IsFalse(_rdfStoreConnector.GetGraph("http://localhost:8890/DAV/").IsEmpty);
// Returns an empty graph, if the graph does not exists
Assert.IsTrue(_rdfStoreConnector.GetGraph("https://test.de/fdgdhjklö/").IsEmpty);
}
[Test]
public void GetOrganizations()
{
Assert.IsFalse(_rdfStoreConnector.GetTriplesByObject(null, null, new Uri("http://www.w3.org/ns/org#FormalOrganization")) == null);
}
//[Test]
public void ShaclTest()
{
var graph = new Graph();
graph.LoadFromString(File.ReadAllText("Metadata.Tests/TestFiles/input.ttl"), new TurtleParser());
//Assert.IsTrue(_util.ValidateShacl(graph));
}
[Test]
public void GetLabel()
{
var graph = _rdfStoreConnector.GetGraph(new Uri("https://www.rwth-aachen.de/"));
OrganizationModel organizationModel = new OrganizationModel(_configuration);
}
}
}