Beispiel #1
0
        public void Build_GivenMultipleInvocations_ShouldCreateIdenticalSequences()
        {
            //Arrange
            var a = new byte[] { 0x00, 0x01 };
            var b = new byte[] { 0x02, 0x03 };

            var builder = new SequenceBuilder <byte>().Append(a).Append(b);

            //Act
            var actual1 = builder.Build().ToArray();
            var actual2 = builder.Build().ToArray();

            //Assert
            var expected = Enumerable.Range(0, 4).ToArray();

            actual1.Should().Equal(expected);
            actual2.Should().Equal(expected);
        }
        public static void RunExample()
        {
            SequenceBuilder builder = new SequenceBuilder("textureChanger");

            builder.Append(VP.Adone().Texture("stone1.jpg", targetName: "myPp01"), TimeSpan.FromSeconds(1));
            builder.Append(VP.Adone().Texture("stone2.jpg", targetName: "myPp01"), TimeSpan.FromSeconds(1));
            builder.Append(VP.Adone().Texture("stone3.jpg", targetName: "myPp01"), TimeSpan.FromSeconds(1));

            foreach (Action action in builder.Build().ToActions())
            {
                Console.WriteLine(action);
            }
        }
Beispiel #3
0
        public void Append_GivenMultipleArrayInputs_ShouldArrangeInCorrectOrder()
        {
            //Arrange
            var a = new byte[] { 0x00, 0x01, 0x02, 0x03 };
            var b = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 };
            var c = new byte[] { 0x09 };
            var builder = new SequenceBuilder<byte>().Append(a).Append(b).Append(c);

            //Act
            var sequence = builder.Build();

            //Assert
            var array = sequence.ToArray();
            for (byte i = 0; i < array.Length; ++i)
                Assert.Equal(i, array[i]);
        }
Beispiel #4
0
        public void Prepend_GivenMultipleArrayInputs_ShouldArrangeInCorrectOrder()
        {
            //Arrange
            var a = new byte[] { 0x00, 0x01, 0x02, 0x03 };
            var b = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 };
            var c = new byte[] { 0x09 };

            var builder = new SequenceBuilder <byte>().Prepend(c).Prepend(b).Prepend(a);

            //Act
            var actual = builder.Build().ToArray();

            //Assert
            var expected = Enumerable.Range(0, 10).ToArray();

            actual.Should().Equal(expected);
        }
        public void ReadUInt32_GivenSequenceWithMultipleSegmentsAndNonZeroStart_ShouldGiveExceptedResult(long start, params byte[][] testPath)
        {
            //Arrange
            var sequenceBuilder = new SequenceBuilder <byte>();

            foreach (var array in testPath)
            {
                sequenceBuilder.Append(array);
            }
            var sequence = sequenceBuilder.Build();

            //Act
            var actual = sequence.ReadUInt32(start, true);

            //Assert
            const uint expected = 0x02030405;

            actual.Should().Be(expected);
        }
Beispiel #6
0
        public void Prepend_GivenMultipleArrayAndSequenceInputs_ShouldArrangeInCorrectOrder()
        {
            //Arrange
            var a = new byte[] { 0x00, 0x01 };
            var b = new byte[] { 0x02, 0x03 };
            var c = new byte[] { 0x04, 0x05 };
            var d = new byte[] { 0x06, 0x07 };
            var e = new byte[] { 0x08, 0x09 };
            var seq = new SequenceBuilder<byte>().Prepend(d).Prepend(c).Prepend(b).Build();
            var builder = new SequenceBuilder<byte>().Prepend(e).Prepend(seq).Prepend(a);

            //Act
            var sequence = builder.Build();

            //Assert
            var array = sequence.ToArray();
            for (byte i = 0; i < array.Length; ++i)
                Assert.Equal(i, array[i]);
        }
Beispiel #7
0
        public void Append_GivenMultipleArrayAndSequenceInputs_ShouldArrangeInCorrectOrder()
        {
            //Arrange
            var a = new byte[] { 0x00, 0x01 };
            var b = new byte[] { 0x02, 0x03 };
            var c = new byte[] { 0x04, 0x05 };
            var d = new byte[] { 0x06, 0x07 };
            var e = new byte[] { 0x08, 0x09 };

            var seq     = new SequenceBuilder <byte>().Append(b).Append(c).Append(d).Build();
            var builder = new SequenceBuilder <byte>().Append(a).Append(seq).Append(e);

            //Act
            var actual = builder.Build().ToArray();

            //Assert
            var expected = Enumerable.Range(0, 10).ToArray();

            actual.Should().Equal(expected);
        }