public void It_should_round_trip_bottom(bool isOpen, Direction facing, WoodSpecies?species, int expectedId, byte expectedData) { if (species != null) // It's a wooden door { // Create the block from IBlock Properties var original = new WoodenDoorBottom(isOpen, facing, (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 WoodenDoorBottom; // Ensure the properties are equivalent coming from the other direction. actual.IsOpen.Should().Be(isOpen); actual.Facing.Should().Be(facing); } else // It's an iron door { // Create the block from IBlock Properties var original = new IronDoorBottom(isOpen, facing); 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 IronDoorBottom; // Ensure the properties are equivalent coming from the other direction. actual.IsOpen.Should().Be(isOpen); actual.Facing.Should().Be(facing); } }
public void It_should_return_a_JavaBlock_for_the_glowstone() { var original = new Glowstone(); var javaBlock = JavaBlock.From(original); javaBlock.Type.Should().Be(BlockType.Glowstone); }
public void It_should_return_a_JavaBlock_for_the_end_stone() { var original = new EndStone(); var javaBlock = JavaBlock.From(original); javaBlock.TypeId.Should().Be(JavaBlockTypes.Id <EndStone>()); }
public void It_should_return_a_JavaBlock_with_variants_as_bytes() { var original = new Stone(Mineral.SmoothAndesite); var javaBlock = JavaBlock.From(original); javaBlock.Type.Should().Be(BlockType.Stone); javaBlock.Data.Parse().Should().Be(Mineral.SmoothAndesite); }
public void It_should_return_a_JavaBlock_with_variants_as_bytes() { var original = new Stone(Mineral.SmoothAndesite); var javaBlock = JavaBlock.From(original); javaBlock.TypeId.Should().Be(JavaBlockTypes.Id <Stone>()); javaBlock.Data.ToEnum <Mineral>().Should().Be(Mineral.SmoothAndesite); }
private void javaBlockRoundTrip(Level level, bool isFlowing, bool isFalling, int expectedId, byte expectedData, IBlock original) { 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 Liquid; // Ensure the properties are equivalent coming from the other direction actual.Level.Should().Be(level); actual.IsFalling.Should().Be(isFalling); actual.IsFlowing.Should().Be(isFlowing); }
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); }
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()); }
public void It_should_round_trip() { // Let's loop over the Java block registry: foreach (var blockType in Types) { var type = blockType.Type; var typeInfo = type.GetTypeInfo(); var typeId = blockType.TypeId; // Look for a parameterless constructor, so we can do the work // without the block author having to bother about it. var ctor = typeInfo.GetConstructor(Type.EmptyTypes); if (ctor != null) { Func <int, IBlock> _ctor = d => (Expression.Lambda <Func <IBlock> >(Expression.New(type))).Compile()(); var original = _ctor(0); var javaBlock = JavaBlock.From(original); var originalTypeId = JavaBlockTypes.GetTypeId(type); javaBlock.Data.Should().Be(0); javaBlock.TypeId.Should().Be(originalTypeId); } } }
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); } }