public void Ctor_ValidData()
    {
        var stroke = new SerializableStroke(_attributes, _points);

        Assert.Equal(stroke.Attributes, _attributes);
        Assert.True(stroke.Points.SequenceEqual(_points));
    }
    public void OverridenEqualsPassNull()
    {
        var stroke = new SerializableStroke(_attributes, _points);
        var result = stroke.Equals(null);

        Assert.False(result);
    }
    public void CtorSerializableStroke()
    {
        var stroke      = new SerializableStroke(_attributes, _points);
        var instruction = new EraseInstruction(stroke);

        Assert.Equal(stroke, instruction.ErasingStroke);
    }
    public void CtorSerializableStroke_ValidData()
    {
        var stroke      = new SerializableStroke(_attributes, _points);
        var instruction = new DrawInstruction(stroke);

        Assert.Equal(stroke, instruction.DrawingStroke);
    }
    public void ExecuteDrawingInstruction_PassNull()
    {
        var stroke      = new SerializableStroke(_attributes, _points);
        var instruction = new EraseInstruction(stroke);

        Assert.Throws <ArgumentNullException>(() => instruction.ExecuteDrawingInstruction(null));
    }
    public void EqualsPassNull()
    {
        IEquatable <SerializableStroke> stroke = new SerializableStroke(_attributes, _points);
        SerializableStroke?anotherStroke       = null;
        var result = stroke.Equals(anotherStroke);

        Assert.False(result);
    }
 public DrawInstruction(Stroke stroke)
 {
     if (stroke == null)
     {
         throw new ArgumentNullException(nameof(stroke));
     }
     DrawingStroke = SerializableStroke.FromStroke(stroke);
 }
    public void ExecuteDrawingInstruction()
    {
        var repositoryMock = new Mock <IDrawingInstructionRepository>();
        var stroke         = new SerializableStroke(_attributes, _points);
        var instruction    = new EraseInstruction(stroke);

        instruction.ExecuteDrawingInstruction(repositoryMock.Object);

        repositoryMock.Verify(instructionRepository => instructionRepository.Erase(instruction), Times.Once);
    }
    public void FromStroke()
    {
        var stroke = SerializableStroke.FromStroke(_nonSerializableStroke);

        Assert.True(stroke.Points.SequenceEqual(_nonSerializableStroke.StylusPoints.Select(sPoint => sPoint.ToPoint())));
        Assert.Equal(stroke.Attributes.Color.AsColor(), _nonSerializableStroke.DrawingAttributes.Color);
        Assert.Equal(stroke.Attributes.Height, _nonSerializableStroke.DrawingAttributes.Height);
        Assert.Equal(stroke.Attributes.Width, _nonSerializableStroke.DrawingAttributes.Width);
        Assert.Equal(stroke.Attributes.IgnorePressure, _nonSerializableStroke.DrawingAttributes.IgnorePressure);
        Assert.Equal(stroke.Attributes.IsHighlighter, _nonSerializableStroke.DrawingAttributes.IsHighlighter);
        Assert.Equal(stroke.Attributes.StylusTip, _nonSerializableStroke.DrawingAttributes.StylusTip);
    }
    public void GetHashCodeForEqualStrokes()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        var anotherStroke = new SerializableStroke(_attributes, anotherPoints);

        var strokeHash        = stroke.GetHashCode();
        var anotherStrokeHash = anotherStroke.GetHashCode();

        Assert.Equal(strokeHash, anotherStrokeHash);
    }
    public void ToStroke()
    {
        var stroke            = new SerializableStroke(_attributes, _points);
        var asNonSerializable = stroke.ToStroke();

        Assert.True(stroke.Points.SequenceEqual(asNonSerializable.StylusPoints.Select(sPoint => sPoint.ToPoint())));
        Assert.Equal(stroke.Attributes.Color.AsColor(), asNonSerializable.DrawingAttributes.Color);
        Assert.Equal(stroke.Attributes.Height, asNonSerializable.DrawingAttributes.Height);
        Assert.Equal(stroke.Attributes.Width, asNonSerializable.DrawingAttributes.Width);
        Assert.Equal(stroke.Attributes.IgnorePressure, asNonSerializable.DrawingAttributes.IgnorePressure);
        Assert.Equal(stroke.Attributes.IsHighlighter, asNonSerializable.DrawingAttributes.IsHighlighter);
        Assert.Equal(stroke.Attributes.StylusTip, asNonSerializable.DrawingAttributes.StylusTip);
    }
    public void OverridenEqualsForEqualStrokes()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        var anotherStroke = new SerializableStroke(_attributes, anotherPoints);

        var strokeInstanceResult        = stroke.Equals((object)anotherStroke);
        var anotherStrokeInstanceResult = anotherStroke.Equals((object)stroke);

        Assert.True(strokeInstanceResult);
        Assert.True(anotherStrokeInstanceResult);
    }
    public void EqualityOperatorsForEqualsStrokes()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        var anotherStroke = new SerializableStroke(_attributes, anotherPoints);

        var equalityResult    = stroke == anotherStroke;
        var nonEqualityResult = stroke != anotherStroke;

        Assert.True(equalityResult);
        Assert.False(nonEqualityResult);
    }
    public void EqualsForNonEqualStrokesByPoints()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        anotherPoints[0] = new Point(anotherPoints[0].X + 1, anotherPoints[0].Y - 1);
        var anotherStroke = new SerializableStroke(_attributes, anotherPoints);

        var strokeInstanceResult        = stroke.Equals(anotherStroke);
        var anotherStrokeInstanceResult = anotherStroke.Equals(stroke);

        Assert.False(strokeInstanceResult);
        Assert.False(anotherStrokeInstanceResult);
    }
    public void GetHashCodeForNonEqualStrokesByPoints()
    {
        var stroke = new SerializableStroke(_attributes, _points);

        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        anotherPoints[0] = new Point(anotherPoints[0].X + 1, anotherPoints[0].Y - 1);
        var anotherStroke = new SerializableStroke(_attributes, anotherPoints);

        var strokeHash        = stroke.GetHashCode();
        var anotherStrokeHash = anotherStroke.GetHashCode();

        Assert.NotEqual(strokeHash, anotherStrokeHash);
    }
Exemple #16
0
    public SerializableStroke BuildSerializable()
    {
        SerializableStroke s = new SerializableStroke();

        s.color  = int.Parse(material.name.Replace("_material", "").Replace("Color", ""));
        s.origin = parent.transform.localPosition;
        s.points = new List <Vector3>();
        var T = parent.transform.parent.transform;
        var p = T.InverseTransformPoint(vertices[0].transform.localPosition);

        foreach (GameObject v in vertices)
        {
            var Tv = T.InverseTransformPoint(v.transform.localPosition);
            s.points.Add(Tv - p);
        }
        return(s);
    }
Exemple #17
0
    public Stroke(SerializableStroke s, GameObject pPfab, GameObject ePfab, GameObject marker, Material mat)
    {
        material    = mat;
        pointPrefab = pPfab;
        edgePrefab  = ePfab;
        vertices    = new List <GameObject>();
        edges       = new List <GameObject>();

        parent = new GameObject("Stroke");
        parent.transform.position = s.origin;

        AddVertex(s.points[0], false);
        for (int i = 1; i < s.points.Count; ++i)
        {
            AddSegment(s.points[i], false);
        }

        parent.transform.SetParent(marker.transform, false);
    }
    public void GetHashCodeForNonEqualStrokesByAttributes()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        var anotherAttributes = new StrokeAttributes
        {
            Color          = ARGBColor.Default,
            Height         = stroke.Attributes.Height + 2,
            Width          = 2,
            IgnorePressure = true,
            IsHighlighter  = !stroke.Attributes.IsHighlighter,
            StylusTip      = StylusTip.Ellipse
        };
        var anotherStroke = new SerializableStroke(anotherAttributes, anotherPoints);

        var strokeHash        = stroke.GetHashCode();
        var anotherStrokeHash = anotherStroke.GetHashCode();

        Assert.NotEqual(strokeHash, anotherStrokeHash);
    }
    public void EqualityOperatorForNonEqualsStrokesByAttributes()
    {
        var stroke        = new SerializableStroke(_attributes, _points);
        var anotherPoints = new Point[_points.Length];

        _points.CopyTo(anotherPoints, 0);
        var anotherAttributes = new StrokeAttributes
        {
            Color          = ARGBColor.Default,
            Height         = stroke.Attributes.Height + 2,
            Width          = 2,
            IgnorePressure = true,
            IsHighlighter  = !stroke.Attributes.IsHighlighter,
            StylusTip      = StylusTip.Ellipse
        };
        var anotherStroke = new SerializableStroke(anotherAttributes, anotherPoints);

        var equalityResult    = stroke == anotherStroke;
        var nonEqualityResult = stroke != anotherStroke;

        Assert.False(equalityResult);
        Assert.True(nonEqualityResult);
    }
 public DrawInstruction(SerializableStroke drawingStroke)
 {
     DrawingStroke = drawingStroke;
 }
 public void FromStrokePassNull()
 {
     Assert.Throws <ArgumentNullException>(() => SerializableStroke.FromStroke(null));
 }