Exemplo n.º 1
0
        public async Task Given_raw_chunk_data_when_deserializing_and_serializing_should_produce_same_binary_representation(string resourceName)
        {
            byte[] rawChunkData = GetType().Assembly.GetManifestResourceStream(GetType(), resourceName).ToArray();
            var    chunk        = new ModelChunk();

            using (var ms = new MemoryStream(rawChunkData))
            {
                await chunk.DeserializeAsync(ms, false);

                // Clear out stream.
                ms.SetLength(0);

                // Act
                await chunk.SerializeAsync(ms, false);

                // Assert
                ms.ToArray().Should().BeEquivalentTo(rawChunkData);
            }
        }
Exemplo n.º 2
0
        public async Task Given_model_when_serializing_and_deserializing_should_produce_same_model(bool includeNormals)
        {
            ModelChunk chunk = GetPopulatedModelChunk(includeNormals);

            using (var ms = new MemoryStream())
            {
                await chunk.SerializeAsync(ms, false);

                ms.Position = 0;

                // Act
                var deserializedChunk = new ModelChunk();
                await deserializedChunk.DeserializeAsync(ms, false);

                // Assert
                deserializedChunk.Should().BeEquivalentTo(chunk, opts =>
                                                          opts.Using(new VectorEquivalencyStep <Vector3>(float.Epsilon))
                                                          .Using(new VectorEquivalencyStep <Vector2>(float.Epsilon)));
                ms.Should().BeEof();
            }
        }