Beispiel #1
0
    public void ExecuteDrawingInstructionPassNull()
    {
        var color       = new ARGBColor(100, 100, 100, 100);
        var instruction = new ChangeBackgroundInstruction(color);

        Assert.Throws <ArgumentNullException>(() => instruction.ExecuteDrawingInstruction(null));
    }
Beispiel #2
0
    public void CtorArgbColor()
    {
        var color       = new ARGBColor(100, 100, 100, 100);
        var instruction = new ChangeBackgroundInstruction(color);

        Assert.Equal(instruction.Background, color);
    }
Beispiel #3
0
    public void ToStringTest()
    {
        var color    = new ARGBColor(78, 123, 255, 18);
        var expected = $"A:{color.A}, R:{color.R}, G:{color.G}, B:{color.B}";

        var result = color.ToString();

        Assert.Equal(expected, result);
    }
Beispiel #4
0
    public void Ctor_ValidDataTheory(byte a, byte r, byte g, byte b)
    {
        var color = new ARGBColor(a, r, g, b);

        Assert.Equal(a, color.A);
        Assert.Equal(r, color.R);
        Assert.Equal(g, color.G);
        Assert.Equal(b, color.B);
    }
Beispiel #5
0
    public void EqualityEquals()
    {
        var color        = new ARGBColor(78, 123, 255, 18);
        var anotherColor = new ARGBColor(78, 123, 255, 18);

        var result = color.Equals(anotherColor);

        Assert.True(result);
    }
Beispiel #6
0
    public void OverriddenEquals()
    {
        var color        = new ARGBColor(78, 123, 255, 18);
        var anotherColor = (object)new ARGBColor(78, 123, 255, 18);

        var result = color.Equals(anotherColor);

        Assert.True(result);
    }
Beispiel #7
0
    public void NonEqualityOperator()
    {
        var color        = new ARGBColor(78, 123, 255, 18);
        var anotherColor = new ARGBColor(78, 123, 255, 18);

        var result = color != anotherColor;

        Assert.False(result);
    }
Beispiel #8
0
    public void GetHashCodeForNonEqualColors()
    {
        var color        = new ARGBColor(78, 123, 255, 18);
        var anotherColor = new ARGBColor(53, 188, 0, 13);

        var hashCode        = color.GetHashCode();
        var anotherHashCode = anotherColor.GetHashCode();

        Assert.NotEqual(hashCode, anotherHashCode);
    }
Beispiel #9
0
    public void FromColor()
    {
        var yellow = Colors.Yellow;
        var result = ARGBColor.FromColor(yellow);

        Assert.Equal(yellow.A, result.A);
        Assert.Equal(yellow.R, result.R);
        Assert.Equal(yellow.G, result.G);
        Assert.Equal(yellow.B, result.B);
    }
Beispiel #10
0
    public void ExecuteDrawingInstruction()
    {
        var repositoryMock = new Mock <IDrawingInstructionRepository>();
        var color          = new ARGBColor(100, 100, 100, 100);
        var instruction    = new ChangeBackgroundInstruction(color);

        instruction.ExecuteDrawingInstruction(repositoryMock.Object);

        repositoryMock.Verify(mock => mock.ChangeBackground(instruction), Times.Once);
    }
Beispiel #11
0
    public void AsColor()
    {
        var yellow = Colors.Yellow;
        var color  = new ARGBColor {
            A = yellow.A, R = yellow.R, G = yellow.G, B = yellow.B
        };

        var result = color.AsColor();

        Assert.Equal(yellow, result);
    }
Beispiel #12
0
        internal static Color FromIColor(IColor color)
        {
            if (null == color)
            {
                return(null);
            }
            ARGBColor c = color as ARGBColor;

            if (null != c)
            {
                return(c);
            }
            return(Color.ByARGB(color.AlphaValue, color.RedValue, color.GreenValue, color.BlueValue));
        }
Beispiel #13
0
 public override void UpdateSensorResponse(ProtocolArray responseData)
 {
     if (SensorType == SensorType.COLOR_FULL)
     {
         RawValue  = (int)responseData.GetBits(1, 3);
         colorData = new ARGBColor(
             (int)responseData.GetBits(1, 10),
             (int)responseData.GetBits(1, 10),
             (int)responseData.GetBits(1, 10),
             (int)responseData.GetBits(1, 10));
     }
     else
     {
         base.UpdateSensorResponse(responseData);
     }
 }
    public static SerializableStroke FromStroke(Stroke stroke)
    {
        if (stroke == null)
        {
            throw new ArgumentNullException(nameof(stroke));
        }
        var attr = new StrokeAttributes
        {
            Color          = ARGBColor.FromColor(stroke.DrawingAttributes.Color),
            Height         = stroke.DrawingAttributes.Height,
            Width          = stroke.DrawingAttributes.Width,
            IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
            IsHighlighter  = stroke.DrawingAttributes.IsHighlighter,
            StylusTip      = stroke.DrawingAttributes.StylusTip
        };

        var points = stroke.StylusPoints.Select(point => point.ToPoint()).ToArray();

        return(new SerializableStroke(attr, points));
    }
 public ChangeBackgroundInstruction(Color background) : this(ARGBColor.FromColor(background))
 {
 }
Beispiel #16
0
 public SnapshotInstruction(ARGBColor background, IEnumerable <SerializableStroke> strokes)
 {
     Background = background;
     Strokes    = strokes ?? throw new ArgumentNullException(nameof(strokes));
 }
 public ChangeBackgroundInstruction(ARGBColor background)
 {
     Background = background;
 }