public void SerializeSimpleObject(XsdPatternReader reader) { var stopwatch = Stopwatch.StartNew(); var pattern = reader.Read(File.ReadAllBytes("Resources/M198_Seaside beauty.xsd")); output.WriteLine($"Pattern: {stopwatch.ElapsedMilliseconds} ms"); var pattern1 = new Pattern(); pattern1.Stitches.Add(pattern.Stitches.Select(stitch => new Stitch { X = stitch.X, Y = stitch.Y, Type = (StitchType)(int)stitch.Type, ConfigurationIndex = stitch.ConfigurationIndex })); stopwatch.Restart(); var patternBytes = pattern1.ToByteArray(); output.WriteLine($"Proto: {stopwatch.ElapsedMilliseconds} ms"); File.WriteAllBytes("proto.pattern", patternBytes); stopwatch.Restart(); var json = JsonConvert.SerializeObject(pattern.Stitches); output.WriteLine($"JSON: {stopwatch.ElapsedMilliseconds} ms"); File.WriteAllBytes("json.pattern", Encoding.UTF8.GetBytes(json)); }
public void ParseXsdPatternFile() { // Arrange var sut = new XsdPatternReader(); // Act var pattern = sut.Read(File.ReadAllBytes("Resources/M198_Seaside beauty.xsd")); // Assert pattern.Stitches.Should().HaveCount(18775); }
public async void DrawExpectedImage(RootContext context, XsdPatternReader patternReader) { //Arrange var props = Props.FromProducer(() => new Superviser()); var pid = context.Spawn(props); var pattern = patternReader.Read(File.ReadAllBytes("Resources/M198_Seaside beauty.xsd")); //Act var thumbnail = await context.RequestAsync <Thumbnail>(pid, pattern); //Assert thumbnail.Image.ToByteArray().Should().Equal(File.ReadAllBytes("Resources/M198_Seaside beauty.png")); }