示例#1
0
                public void It_should_return_a_stone_block_with_the_variant_specified(byte serializedData, Mineral?expected)
                {
                    var actual = JavaBlock.Create(JavaBlockTypes.Id <Stone>(), serializedData) as Stone;

                    actual.Should().NotBeNull("deserializing a Stone block should return a Stone object");
                    actual.Mineral.Should().Be(expected, "the variant should be deserialized correctly");
                }
示例#2
0
                public void It_should_return_an_end_stone()
                {
                    var blockType = JavaBlockTypes.Id <EndStone>();

                    var deserialized = JavaBlock.Create(blockType, 0) as EndStone;

                    deserialized.Should().NotBeNull();
                }
示例#3
0
                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>());
                }
示例#4
0
                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);
                }
示例#5
0
                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);
                        }
                    }
                }