Example #1
0
                public void It_should_round_trip_simple_rails(RailDirections directions, int expectedId, byte expectedData)
                {
                    // Create the block from IBlock Properties
                    Rail original = new Rail(directions);

                    var javaBlock = JavaBlock.From(original);

                    javaBlock.TypeId.Should().Be(expectedId);
                    javaBlock.Data.Should().Be(expectedData);

                    // Create Block from id and data
                    var actual = JavaBlock.Create(expectedId, expectedData) as Rail;

                    // Ensure the properties are equivalent coming from the other direction
                    actual.IsAscending.Should().Be(original.IsAscending);
                    actual.IsTurning.Should().Be(original.IsTurning);
                    actual.Directions.Should().Be(original.Directions);
                }
Example #2
0
                public void It_should_round_trip_activatable_rails(RailDirections directions, Type t, bool isActive, int expectedId, byte expectedData)
                {
                    // Create the block from IBlock Properties
                    Activator.CreateInstance(t, directions, isActive);
                    var original = Activator.CreateInstance(t, directions, isActive) as IActivatableRail;

                    var javaBlock = JavaBlock.From((IBlock)original);

                    // Create Block from id and data
                    javaBlock.TypeId.Should().Be(expectedId);
                    javaBlock.Data.Should().Be(expectedData);

                    // Ensure the properties are equivalent coming from the other direction
                    var actual = JavaBlock.Create(expectedId, expectedData) as IActivatableRail;

                    actual.IsAscending.Should().Be(original.IsAscending);
                    actual.IsTurning.Should().Be(original.IsTurning);
                    actual.IsActive.Should().Be(original.IsActive);
                    actual.Directions.Should().Be(original.Directions);

                    // Verify the right types come from both directions.
                    actual.GetType().Should().Be(original.GetType());
                }
Example #3
0
                public void It_should_round_trip_a_top(bool isHingeOnTheRight, bool isPowered, WoodSpecies?species, int expectedId, byte expectedData)
                {
                    if (species != null) // It's a wooden door
                    {
                        // Create the block from IBlock Properties
                        var original  = new WoodenDoorTop(isHingeOnTheRight, isPowered, (WoodSpecies)species);
                        var javaBlock = JavaBlock.From(original);

                        javaBlock.TypeId.Should().Be(expectedId);
                        javaBlock.Data.Should().Be(expectedData);

                        // Create Block from id and data
                        var actual = JavaBlock.Create(expectedId, expectedData) as WoodenDoorTop;

                        // Ensure the properties are equivalent coming from the other direction.
                        actual.Species.Should().Be(species);
                        actual.IsPowered.Should().Be(isPowered);
                        actual.IsHingeOnTheRight.Should().Be(isHingeOnTheRight);
                    }
                    else // It's an iron door
                    {
                        // Create the block from IBlock Properties
                        var original  = new IronDoorTop(isHingeOnTheRight, isPowered);
                        var javaBlock = JavaBlock.From(original);

                        javaBlock.TypeId.Should().Be(expectedId);
                        javaBlock.Data.Should().Be(expectedData);

                        // Create Block from id and data
                        var actual = JavaBlock.Create(expectedId, expectedData) as IronDoorTop;

                        // Ensure the properties are equivalent coming from the other direction.
                        actual.IsPowered.Should().Be(isPowered);
                        actual.IsHingeOnTheRight.Should().Be(isHingeOnTheRight);
                    }
                }