Skip to content

Commit

Permalink
squash! Dependency update (#2)
Browse files Browse the repository at this point in the history
* Add package generation for Ivet.Model

* Improve documentation

* Update dependencies + Ivet package

* Fix Gremlinq API changements

* Code improvement

* Remove useless conf
  • Loading branch information
etrange02 committed Mar 3, 2024
1 parent 9c0e07f commit 1975122
Show file tree
Hide file tree
Showing 37 changed files with 343 additions and 215 deletions.
7 changes: 7 additions & 0 deletions Ivet.Model/AbstractEdge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Ivet.Model
{
public abstract class AbstractEdge
{
public long? Id { get; set; }
}
}
7 changes: 7 additions & 0 deletions Ivet.Model/AbstractVertex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Ivet.Model
{
public abstract class AbstractVertex
{
public long? Id { get; set; }
}
}
16 changes: 16 additions & 0 deletions Ivet.Model/Ivet.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>david.lecoconnier</Authors>
<Version>1.1.0</Version>
<Title>Ivet.Model</Title>
<PackageProjectUrl>https://github.com/etrange02/Ivet</PackageProjectUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/etrange02/Ivet</RepositoryUrl>
<Description>Ivet's attributes. Tag your code with these classes then use Ivet to generate and update your Janusgraph schema</Description>
<PackageLicenseExpression>CECILL-B</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="..\Readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
18 changes: 9 additions & 9 deletions Ivet.TestFramework/RandomGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
public class RandomGenerator
{
private static Random _random = new Random();
private static readonly Random _random = new();

public string RandomString() => Guid.NewGuid().ToString();
public int RandomInt() => _random.Next();
public int RandomInt(int max) => _random.Next() % (max + 1);
public int RandomInt(int min, int max) => (_random.Next() + min) % (max + 1);
public double RandomDouble() => _random.NextDouble();
public bool RandomBool() => RandomInt() % 2 == 0;
public Guid RandomGuid() => Guid.NewGuid();
public T RandomEnum<T>() where T : Enum
public static string RandomString() => Guid.NewGuid().ToString();
public static int RandomInt() => _random.Next();
public static int RandomInt(int max) => _random.Next() % (max + 1);
public static int RandomInt(int min, int max) => (_random.Next() + min) % (max + 1);
public static double RandomDouble() => _random.NextDouble();
public static bool RandomBool() => RandomInt() % 2 == 0;
public static Guid RandomGuid() => Guid.NewGuid();
public static T RandomEnum<T>() where T : Enum
{
var enumValues = Enum.GetValues(typeof(T));
return (T)enumValues.GetValue(_random.Next(enumValues.Length));

Check warning on line 17 in Ivet.TestFramework/RandomGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 17 in Ivet.TestFramework/RandomGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
Expand Down
4 changes: 2 additions & 2 deletions Ivet.TestModel/Vertex1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class Vertex1
public string Id { get; set; }

Check warning on line 10 in Ivet.TestModel/Vertex1.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Id' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[EdgeProperty]
public List<Vertex3> vertex3s { get; private set; } = new List<Vertex3>();
public List<Vertex3> Vertex3s { get; private set; } = new List<Vertex3>();

[EdgeProperty]
public Vertex3[] array_vertex3s { get; private set; }
public Vertex3[] ArrayVertex3s { get; private set; } = Array.Empty<Vertex3>();
}
}
10 changes: 5 additions & 5 deletions Ivet.Tests/Ivet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions Ivet.Tests/Services/Comparers/CompositeIndexComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void EqualsTest_SameName()
{
// Arrange
var sut = new CompositeIndexComparer();
var name = _randomGenerator.RandomString();
var name = RandomGenerator.RandomString();
var a = new MetaCompositeIndex { Name = name };
var b = new MetaCompositeIndex { Name = name };

Expand All @@ -30,8 +30,8 @@ public void EqualsTest_DifferentName()
{
// Arrange
var sut = new CompositeIndexComparer();
var a = new MetaCompositeIndex { Name = _randomGenerator.RandomString() };
var b = new MetaCompositeIndex { Name = _randomGenerator.RandomString() };
var a = new MetaCompositeIndex { Name = RandomGenerator.RandomString() };
var b = new MetaCompositeIndex { Name = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand Down
30 changes: 15 additions & 15 deletions Ivet.Tests/Services/Comparers/ConnectionComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public void EqualsTest_AllPropertiesEquals()
{
// Arrange
var sut = new ConnectionComparer();
var edge = _randomGenerator.RandomString();
var ingoing = _randomGenerator.RandomString();
var outgoing = _randomGenerator.RandomString();
var edge = RandomGenerator.RandomString();
var ingoing = RandomGenerator.RandomString();
var outgoing = RandomGenerator.RandomString();
var a = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = outgoing };
var b = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = outgoing };

Expand All @@ -32,10 +32,10 @@ public void EqualsTest_EdgeDifferent()
{
// Arrange
var sut = new ConnectionComparer();
var ingoing = _randomGenerator.RandomString();
var outgoing = _randomGenerator.RandomString();
var a = new MetaConnection { Edge = _randomGenerator.RandomString(), Ingoing = ingoing, Outgoing = outgoing };
var b = new MetaConnection { Edge = _randomGenerator.RandomString(), Ingoing = ingoing, Outgoing = outgoing };
var ingoing = RandomGenerator.RandomString();
var outgoing = RandomGenerator.RandomString();
var a = new MetaConnection { Edge = RandomGenerator.RandomString(), Ingoing = ingoing, Outgoing = outgoing };
var b = new MetaConnection { Edge = RandomGenerator.RandomString(), Ingoing = ingoing, Outgoing = outgoing };

// Act
var result = sut.Equals(a, b);
Expand All @@ -49,10 +49,10 @@ public void EqualsTest_IngoingDifferent()
{
// Arrange
var sut = new ConnectionComparer();
var edge = _randomGenerator.RandomString();
var outgoing = _randomGenerator.RandomString();
var a = new MetaConnection { Edge = edge, Ingoing = _randomGenerator.RandomString(), Outgoing = outgoing };
var b = new MetaConnection { Edge = edge, Ingoing = _randomGenerator.RandomString(), Outgoing = outgoing };
var edge = RandomGenerator.RandomString();
var outgoing = RandomGenerator.RandomString();
var a = new MetaConnection { Edge = edge, Ingoing = RandomGenerator.RandomString(), Outgoing = outgoing };
var b = new MetaConnection { Edge = edge, Ingoing = RandomGenerator.RandomString(), Outgoing = outgoing };

// Act
var result = sut.Equals(a, b);
Expand All @@ -66,10 +66,10 @@ public void EqualsTest_OutgoingDifferent()
{
// Arrange
var sut = new ConnectionComparer();
var edge = _randomGenerator.RandomString();
var ingoing = _randomGenerator.RandomString();
var a = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = _randomGenerator.RandomString() };
var b = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = _randomGenerator.RandomString() };
var edge = RandomGenerator.RandomString();
var ingoing = RandomGenerator.RandomString();
var a = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = RandomGenerator.RandomString() };
var b = new MetaConnection { Edge = edge, Ingoing = ingoing, Outgoing = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand Down
16 changes: 8 additions & 8 deletions Ivet.Tests/Services/Comparers/IndexBindingComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public void EqualsTest_AllPropertiesEquals()
{
// Arrange
var sut = new IndexBindingComparer();
var indexName = _randomGenerator.RandomString();
var propertyName = _randomGenerator.RandomString();
var indexName = RandomGenerator.RandomString();
var propertyName = RandomGenerator.RandomString();
var a = new MetaIndexBinding { IndexName = indexName, PropertyName = propertyName };
var b = new MetaIndexBinding { IndexName = indexName, PropertyName = propertyName };

Expand All @@ -31,9 +31,9 @@ public void EqualsTest_EdgeDifferent()
{
// Arrange
var sut = new IndexBindingComparer();
var indexName = _randomGenerator.RandomString();
var a = new MetaIndexBinding { IndexName = indexName, PropertyName = _randomGenerator.RandomString() };
var b = new MetaIndexBinding { IndexName = indexName, PropertyName = _randomGenerator.RandomString() };
var indexName = RandomGenerator.RandomString();
var a = new MetaIndexBinding { IndexName = indexName, PropertyName = RandomGenerator.RandomString() };
var b = new MetaIndexBinding { IndexName = indexName, PropertyName = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand All @@ -47,9 +47,9 @@ public void EqualsTest_PropertyNameDifferent()
{
// Arrange
var sut = new IndexBindingComparer();
var indexName = _randomGenerator.RandomString();
var a = new MetaIndexBinding { IndexName = indexName, PropertyName = _randomGenerator.RandomString() };
var b = new MetaIndexBinding { IndexName = indexName, PropertyName = _randomGenerator.RandomString() };
var indexName = RandomGenerator.RandomString();
var a = new MetaIndexBinding { IndexName = indexName, PropertyName = RandomGenerator.RandomString() };
var b = new MetaIndexBinding { IndexName = indexName, PropertyName = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand Down
6 changes: 3 additions & 3 deletions Ivet.Tests/Services/Comparers/MixedIndexComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void EqualsTest_SameName()
{
// Arrange
var sut = new MixedIndexComparer();
var name = _randomGenerator.RandomString();
var name = RandomGenerator.RandomString();
var a = new MetaMixedIndex { Name = name };
var b = new MetaMixedIndex { Name = name };

Expand All @@ -30,8 +30,8 @@ public void EqualsTest_DifferentName()
{
// Arrange
var sut = new MixedIndexComparer();
var a = new MetaMixedIndex { Name = _randomGenerator.RandomString() };
var b = new MetaMixedIndex { Name = _randomGenerator.RandomString() };
var a = new MetaMixedIndex { Name = RandomGenerator.RandomString() };
var b = new MetaMixedIndex { Name = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand Down
16 changes: 8 additions & 8 deletions Ivet.Tests/Services/Comparers/PropertyBindingComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public void EqualsTest_AllPropertiesEquals()
{
// Arrange
var sut = new PropertyBindingComparer();
var entity = _randomGenerator.RandomString();
var name = _randomGenerator.RandomString();
var entity = RandomGenerator.RandomString();
var name = RandomGenerator.RandomString();
var a = new MetaPropertyBinding { Entity = entity, Name = name };
var b = new MetaPropertyBinding { Entity = entity, Name = name };

Expand All @@ -31,9 +31,9 @@ public void EqualsTest_EntityDifferent()
{
// Arrange
var sut = new PropertyBindingComparer();
var name = _randomGenerator.RandomString();
var a = new MetaPropertyBinding { Entity = _randomGenerator.RandomString(), Name = name };
var b = new MetaPropertyBinding { Entity = _randomGenerator.RandomString(), Name = name };
var name = RandomGenerator.RandomString();
var a = new MetaPropertyBinding { Entity = RandomGenerator.RandomString(), Name = name };
var b = new MetaPropertyBinding { Entity = RandomGenerator.RandomString(), Name = name };

// Act
var result = sut.Equals(a, b);
Expand All @@ -47,9 +47,9 @@ public void EqualsTest_NameDifferent()
{
// Arrange
var sut = new PropertyBindingComparer();
var entity = _randomGenerator.RandomString();
var a = new MetaPropertyBinding { Entity = entity, Name = _randomGenerator.RandomString() };
var b = new MetaPropertyBinding { Entity = entity, Name = _randomGenerator.RandomString() };
var entity = RandomGenerator.RandomString();
var a = new MetaPropertyBinding { Entity = entity, Name = RandomGenerator.RandomString() };
var b = new MetaPropertyBinding { Entity = entity, Name = RandomGenerator.RandomString() };

// Act
var result = sut.Equals(a, b);
Expand Down
18 changes: 9 additions & 9 deletions Ivet.Tests/Services/Converters/DatabaseToSchemaConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void ConvertTest_Empty()
public void ConvertTest_Vertex()
{
// Arrange
var entity = new Vertex { Name = _random.RandomString(), Partitioned = _random.RandomBool(), Static = _random.RandomBool() };
var entity = new Model.Database.Vertex { Name = RandomGenerator.RandomString(), Partitioned = RandomGenerator.RandomBool(), Static = RandomGenerator.RandomBool() };
var schema = new Schema
{
Vertices = { entity }
Expand Down Expand Up @@ -65,7 +65,7 @@ public void ConvertTest_Vertex()
public void ConvertTest_Edge()
{
// Arrange
var entity = new Edge { Name = _random.RandomString(), Directed = _random.RandomBool(), Multiplicity = _random.RandomEnum<Multiplicity>(), Unidirected = _random.RandomBool() };
var entity = new Model.Database.Edge { Name = RandomGenerator.RandomString(), Directed = RandomGenerator.RandomBool(), Multiplicity = RandomGenerator.RandomEnum<Multiplicity>(), Unidirected = RandomGenerator.RandomBool() };
var schema = new Schema
{
Edges = { entity }
Expand Down Expand Up @@ -93,7 +93,7 @@ public void ConvertTest_Edge()
public void ConvertTest_Connection()
{
// Arrange
var entity = new Connection { Edge = _random.RandomString(), Ingoing = _random.RandomString(), Outgoing = _random.RandomString() };
var entity = new Connection { Edge = RandomGenerator.RandomString(), Ingoing = RandomGenerator.RandomString(), Outgoing = RandomGenerator.RandomString() };
var schema = new Schema
{
Connections = { entity }
Expand Down Expand Up @@ -122,7 +122,7 @@ public void ConvertTest_Connection()
public void ConvertTest_PropertyKey()
{
// Arrange
var entity = new PropertyKey { Name = _random.RandomString(), DataType = _random.RandomString(), Cardinality = _random.RandomEnum<Cardinality>() };
var entity = new PropertyKey { Name = RandomGenerator.RandomString(), DataType = RandomGenerator.RandomString(), Cardinality = RandomGenerator.RandomEnum<Cardinality>() };
var schema = new Schema
{
PropertyKeys = { entity }
Expand Down Expand Up @@ -151,7 +151,7 @@ public void ConvertTest_PropertyKey()
public void ConvertTest_EdgePropertyKeyBinding()
{
// Arrange
var entity = new PropertyBinding { Name = _random.RandomString(), Entity = _random.RandomString() };
var entity = new PropertyBinding { Name = RandomGenerator.RandomString(), Entity = RandomGenerator.RandomString() };
var schema = new Schema
{
EdgesPropertyBindings = { entity }
Expand Down Expand Up @@ -179,7 +179,7 @@ public void ConvertTest_EdgePropertyKeyBinding()
public void ConvertTest_VertexPropertyKeyBinding()
{
// Arrange
var entity = new PropertyBinding { Name = _random.RandomString(), Entity = _random.RandomString() };
var entity = new PropertyBinding { Name = RandomGenerator.RandomString(), Entity = RandomGenerator.RandomString() };
var schema = new Schema
{
VertexPropertyBindings = { entity }
Expand Down Expand Up @@ -207,7 +207,7 @@ public void ConvertTest_VertexPropertyKeyBinding()
public void ConvertTest_MixedIndices()
{
// Arrange
var entity = new Model.Database.Index { Name = _random.RandomString(), BackendIndex = _random.RandomString(), IndexedElement = _random.RandomString(), IsUnique = _random.RandomBool(), IsCompositeIndex = false, IsMixedIndex = true };
var entity = new Model.Database.Index { Name = RandomGenerator.RandomString(), BackendIndex = RandomGenerator.RandomString(), IndexedElement = RandomGenerator.RandomString(), IsUnique = RandomGenerator.RandomBool(), IsCompositeIndex = false, IsMixedIndex = true };
var schema = new Schema
{
Indices = { entity }
Expand Down Expand Up @@ -237,7 +237,7 @@ public void ConvertTest_MixedIndices()
public void ConvertTest_CompositeIndices()
{
// Arrange
var entity = new Model.Database.Index { Name = _random.RandomString(), BackendIndex = _random.RandomString(), IndexedElement = _random.RandomString(), IsUnique = _random.RandomBool(), IsCompositeIndex = true, IsMixedIndex = false };
var entity = new Model.Database.Index { Name = RandomGenerator.RandomString(), BackendIndex = RandomGenerator.RandomString(), IndexedElement = RandomGenerator.RandomString(), IsUnique = RandomGenerator.RandomBool(), IsCompositeIndex = true, IsMixedIndex = false };
var schema = new Schema
{
Indices = { entity }
Expand Down Expand Up @@ -267,7 +267,7 @@ public void ConvertTest_CompositeIndices()
public void ConvertTest_IndexBindings()
{
// Arrange
var entity = new IndexBinding { IndexName = _random.RandomString(), Parameter = _random.RandomString(), PropertyName = _random.RandomString() };
var entity = new IndexBinding { IndexName = RandomGenerator.RandomString(), Parameter = RandomGenerator.RandomString(), PropertyName = RandomGenerator.RandomString() };
var schema = new Schema
{
IndexBindings = { entity }
Expand Down
Loading

0 comments on commit 1975122

Please sign in to comment.