HashSetDependencyNode
This commit is contained in:
parent
004348f024
commit
beebf3e7c8
@ -0,0 +1,15 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
||||||
|
public class HashSetDependencyNode : IDependencyNode {
|
||||||
|
public NodeProfile Profile { get; }
|
||||||
|
public ICollection<NodeProfile> Sources { get; }
|
||||||
|
public ICollection<NodeProfile> Destinations { get; }
|
||||||
|
|
||||||
|
public HashSetDependencyNode(NodeProfile profile) {
|
||||||
|
Profile = profile;
|
||||||
|
Sources = new HashSet<NodeProfile>();
|
||||||
|
Destinations = new HashSet<NodeProfile>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b278ba5cdda49eca5f5aa0b2941713d
|
||||||
|
timeCreated: 1605450089
|
@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
||||||
|
public interface IDependencyNode {
|
||||||
|
NodeProfile Profile { get; }
|
||||||
|
ICollection<NodeProfile> Sources { get; }
|
||||||
|
ICollection<NodeProfile> Destinations { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 365c6defe4c649a496963187a24ffca0
|
||||||
|
timeCreated: 1605449577
|
@ -1,26 +1,35 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
||||||
public readonly struct NodeProfile : IEquatable<NodeProfile> {
|
public class NodeProfile : IEquatable<NodeProfile> {
|
||||||
public readonly NodeId id;
|
public NodeId Id { get; }
|
||||||
public readonly string name;
|
public string Name { set; get; }
|
||||||
|
|
||||||
public NodeProfile(NodeId id, string name) {
|
public NodeProfile(NodeId id, string name) {
|
||||||
this.id = id;
|
Id = id;
|
||||||
this.name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(NodeProfile other) {
|
public bool Equals(NodeProfile other)
|
||||||
return id.Equals(other.id) && name == other.name;
|
{
|
||||||
|
if (ReferenceEquals(null, other)) return false;
|
||||||
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
return Id.Equals(other.Id) && Name == other.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj) {
|
public override bool Equals(object obj)
|
||||||
return obj is NodeProfile other && Equals(other);
|
{
|
||||||
|
if (ReferenceEquals(null, obj)) return false;
|
||||||
|
if (ReferenceEquals(this, obj)) return true;
|
||||||
|
if (obj.GetType() != this.GetType()) return false;
|
||||||
|
return Equals((NodeProfile) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() {
|
public override int GetHashCode()
|
||||||
unchecked {
|
{
|
||||||
return (id.GetHashCode() * 397) ^ (name != null ? name.GetHashCode() : 0);
|
unchecked
|
||||||
|
{
|
||||||
|
return (Id.GetHashCode() * 397) ^ (Name != null ? Name.GetHashCode() : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
|
||||||
|
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Tests {
|
||||||
|
public class HashSetDependencyNodeTest {
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHashSetDependencyNode() {
|
||||||
|
var node = new HashSetDependencyNode(new NodeProfile(new NodeId(1), "node"));
|
||||||
|
Assert.That(node, Is.InstanceOf<IDependencyNode>());
|
||||||
|
Assert.That(node.Profile.Id, Is.EqualTo(1));
|
||||||
|
Assert.That(node.Profile.Name, Is.EqualTo("node"));
|
||||||
|
Assert.That(node.Sources, Is.Empty);
|
||||||
|
Assert.That(node.Destinations, Is.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd573c4b7c3d450da36047e4e1e03824
|
||||||
|
timeCreated: 1605450304
|
@ -9,8 +9,8 @@ namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Tests {
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNodeProfile() {
|
public void TestNodeProfile() {
|
||||||
var nodeProfile = new NodeProfile(new NodeId(123), "testNode");
|
var nodeProfile = new NodeProfile(new NodeId(123), "testNode");
|
||||||
Assert.That(nodeProfile.id.value, Is.EqualTo(123));
|
Assert.That(nodeProfile.Id.value, Is.EqualTo(123));
|
||||||
Assert.That(nodeProfile.name, Is.EqualTo("testNode"));
|
Assert.That(nodeProfile.Name, Is.EqualTo("testNode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -24,5 +24,13 @@ namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Tests {
|
|||||||
Assert.That(profile1, Is.Not.EqualTo(profile3));
|
Assert.That(profile1, Is.Not.EqualTo(profile3));
|
||||||
Assert.That(profile1, Is.EqualTo(profile4));
|
Assert.That(profile1, Is.EqualTo(profile4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNodeProfileName() {
|
||||||
|
var nodeProfile = new NodeProfile(new NodeId(123), "hoge");
|
||||||
|
nodeProfile.Name = "testNode";
|
||||||
|
Assert.That(nodeProfile.Name, Is.EqualTo("testNode"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user