public void SequentialReaderWriter_SerializeHugeObject() { var single = new SimpleFlatClass { StringField = new string('a', 16254), ByteArrayField = Encoding.ASCII.GetBytes(new string('b', 65666)), ZeroByteArrayField = Encoding.ASCII.GetBytes(new string('c', 128344)) }; var expected = new List<SimpleFlatClass> { single, single, single, }; var w = AvroContainer.CreateWriter<SimpleFlatClass>(this.resultStream, new AvroSerializerSettings { Resolver = new AvroDataContractResolver(true) }, Codec.Null); using (var writer = new SequentialWriter<SimpleFlatClass>(w, 24)) { expected.ForEach(writer.Write); } this.resultStream.Seek(0, SeekOrigin.Begin); var r = AvroContainer.CreateReader<SimpleFlatClass>(this.resultStream, true, new AvroSerializerSettings { Resolver = new AvroDataContractResolver(true) }, new CodecFactory()); using (var reader = new SequentialReader<SimpleFlatClass>(r)) { Assert.IsTrue(expected.SequenceEqual(reader.Objects)); } }
public void FeatureMatcherGeneratesCastMatcherMismatchDesciptionsCorrectlyWhenCastFails() { var sut = Describe.Object <SimpleFlatClass>() .Cast <DerivedFlatClass>(c => c.Property(x => x.AnotherIntProperty, new FakeMatcher <int>(true, "", i => ""))); var expectedDescription = "was a(n) SimpleFlatClass where:\r\n" + " it was not of type DerivedFlatClass"; var mismatched = new SimpleFlatClass(); sut.ShouldHaveMismatchDescriptionForValue(mismatched, expectedDescription); }
public void FeatureMatcherGeneratesCorrectMismatchDescriptionForOnlyFailedProperties( int intVal, string stringVal, int mismatchedIntVal, string mismatchedStringVal, string mismatchedStringDescription) { var sut = Describe.Object <SimpleFlatClass>() .Property(x => x.IntProperty, new FakeMatcher <int>(true, "", i => "")) .Property(x => x.StringProperty, new FakeMatcher <string>(false, "", i => i == mismatchedStringVal ? mismatchedStringDescription : i)); var expectedDescription = "was a(n) SimpleFlatClass where:\r\n" + " member StringProperty value " + mismatchedStringDescription; var mismatched = new SimpleFlatClass { IntProperty = mismatchedIntVal, StringProperty = mismatchedStringVal }; sut.ShouldHaveMismatchDescriptionForValue(mismatched, expectedDescription); }
public void Container_SerializeHugeObject() { var single = new SimpleFlatClass { StringField = new string('a', 16254), ByteArrayField = Encoding.ASCII.GetBytes(new string('b', 65666)), ZeroByteArrayField = Encoding.ASCII.GetBytes(new string('c', 128344)) }; var expected = new List<SimpleFlatClass> { single, single, single, }; var writer = AvroContainer.CreateWriter<SimpleFlatClass>(this.resultStream, new AvroSerializerSettings { Resolver = new AvroDataContractResolver(true) }, Codec.Null); var block = writer.CreateBlockAsync().Result; expected.ForEach(block.Write); writer.WriteBlockAsync(block).Wait(); writer.Dispose(); this.resultStream.Seek(0, SeekOrigin.Begin); var reader = AvroContainer.CreateReader<SimpleFlatClass>(this.resultStream, true, new AvroSerializerSettings { Resolver = new AvroDataContractResolver(true) }, new CodecFactory()); reader.MoveNext(); Assert.IsTrue(expected.SequenceEqual(reader.Current.Objects)); }