public void When_creating_new_instance_should_set_defaults() { var newInstance = new MaterialChunk(); var compareToInstance = new MaterialChunk { ParentFile = null, FileOffset = 0, Magic = DatFile.Magics.Material, Id = 0, SubType = 0, Attributes = MaterialAttributes.MagFilterLinear | MaterialAttributes.MinFilterLinear, Diffuse = Color.FromArgb(149, 149, 149), Opacity = 255, SpecularMode = SpecularMode.Normal, Specular = Color.FromArgb(229, 229, 229), SpecularStrength = 0, Glossiness = 0, Emission = 0, CreationTime = DateTime.UtcNow, Texture = null, TgaTextureSize = 0 }; // Assert newInstance.Should().BeEquivalentTo(compareToInstance); }
public async Task When_serializing_and_then_deserializing_should_produce_equivalent(string texture, int tgaTextureSize) { var chunk = new MaterialChunk { Id = 456, CreationTime = new DateTime(2008, 8, 13, 16, 50, 13), Texture = texture, TgaTextureSize = tgaTextureSize }; using (var ms = new MemoryStream()) { await chunk.SerializeAsync(ms, false); ms.Position = 0; // Act var deserializedChunk = new MaterialChunk(); await deserializedChunk.DeserializeAsync(ms, false); // Assert if (deserializedChunk.HasTextureReference) { deserializedChunk.Should().BeEquivalentTo(chunk); } else { deserializedChunk.Should().BeEquivalentTo(chunk, opts => opts .Excluding(c => c.CreationTime) .Excluding(c => c.Texture)); } ms.Should().BeEof(); } }