public void Component_SerializeSmallerClassAndReadBigger_NoError() { //Arrange SmallerNestedTestClass toSerialize = _fixture.Create <SmallerNestedTestClass>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <NestedTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.justSomeProperty, deserialized.justSomeProperty); }
public void Serialize_ObjectContainsGuid_ResultIsTheSameAsInput() { //Arrange ClassWithGuid testClass = _fixture.Create <ClassWithGuid>(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithGuid>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass.theGuid, deserialized.theGuid); }
public void Component_ObjectIsDictionaryOfComplexTypes_ResultIsTheSameAsInput() { //Arrange Dictionary <Uri, SomeTestClass> dictionary = _fixture.Create <Dictionary <Uri, SomeTestClass> >(); //Act var result = AvroConvert.Serialize(dictionary); var deserialized = AvroConvert.Deserialize <Dictionary <Uri, SomeTestClass> >(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(dictionary, deserialized); }
public void Component_DictionaryOfEnums_ResultIsTheSameAsInput() { //Arrange Dictionary <TestEnum, TestEnum> toSerialize = _fixture.Create <Dictionary <TestEnum, TestEnum> >(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <Dictionary <TestEnum, TestEnum> >(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize, deserialized); }
public void Component_ObjectIsList_ResultIsTheSameAsInput() { //Arrange List <int> dictionary = _fixture.Create <List <int> >(); //Act var result = AvroConvert.Serialize(dictionary); var deserialized = AvroConvert.Deserialize <List <int> >(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(dictionary, deserialized); }
public void Component_ObjectIsArray_ResultIsTheSameAsInput() { //Arrange int[] array = _fixture.Create <int[]>(); //Act var result = AvroConvert.Serialize(array); var deserialized = AvroConvert.Deserialize <int[]>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(array, deserialized); }
public void Component_ListOfEnums_ResultIsTheSameAsInput() { //Arrange List <TestEnum> toSerialize = _fixture.CreateMany <TestEnum>(20).ToList(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <List <TestEnum> >(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize, deserialized); }
public void Component_ObjectIsHashSet_ResultIsTheSameAsInput() { //Arrange HashSet <int> hashset = _fixture.Create <HashSet <int> >(); //Act var result = AvroConvert.Serialize(hashset); var deserialized = AvroConvert.Deserialize <HashSet <int> >(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(hashset, deserialized); }
public void SerializeClassWithList_ThenDeserialize_ListsAreEqual() { //Arrange SomeTestClass someTestClass = new SomeTestClass { objectProperty = new NestedTestClass { justSomeProperty = "spoko", andLongProperty = 2137 }, simpleProperty = 111111 }; SomeTestClass dupa2 = new SomeTestClass { objectProperty = new NestedTestClass { justSomeProperty = "loko", andLongProperty = 2137 }, simpleProperty = 2135 }; SomeTestClass[] someTestClasses = new SomeTestClass[2]; someTestClasses[0] = someTestClass; someTestClasses[1] = dupa2; //Act var serialized = AvroConvert.Serialize(someTestClasses); var result = new List <SomeTestClass>(); using (var reader = AvroConvert.OpenDeserializer <SomeTestClass>(new MemoryStream(serialized))) { while (reader.HasNext()) { var item = reader.ReadNext(); result.Add(item); } } //Assert Assert.NotNull(result); Assert.Equal(someTestClasses, result); }
public void Serialize_ObjectContainsLists_ResultIsTheSameAsInput() { //Arrange ClassWithSimpleList testClass = _fixture.Create <ClassWithSimpleList>(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithSimpleList>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass.someList.Count, deserialized.someList.Count); }
public void Component_SerializeConcurrentBagClass_ResultIsTheSameAsInput() { //Arrange ConcurrentBagClass toSerialize = _fixture.Create <ConcurrentBagClass>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <ConcurrentBagClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize, deserialized); }
public void Deflate_SerializeAndDeserializeComplexClass_NoError() { //Arrange BiggerNestedTestClass toSerialize = _fixture.Create <BiggerNestedTestClass>(); //Act var result = AvroConvert.Serialize(toSerialize, CodecType.Deflate); var deserialized = AvroConvert.Deserialize <BiggerNestedTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize, deserialized); }
public void Component_MultidimensionalArray_ResultIsTheSameAsInput() { //Arrange MultidimensionalArrayClass array = _fixture.Create <MultidimensionalArrayClass>(); //Act var result = AvroConvert.Serialize(array); var deserialized = AvroConvert.Deserialize <MultidimensionalArrayClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(array, deserialized); }
public void Avro2Json_ConvertNull_ProducedDesiredJson() { //Arrange string nullTestObject = null; var expectedJson = JsonConvert.SerializeObject(nullTestObject); var avroSerialized = AvroConvert.Serialize(nullTestObject); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Avro2Json_ConvertString_ProducedDesiredJson() { //Arrange var @string = "I am the serialization string"; var expectedJson = JsonConvert.SerializeObject(@string); var avroSerialized = AvroConvert.Serialize(@string); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Component_SerializeBiggerAvroObjectAndReadSmaller_NoError() { //Arrange AttributeClass toSerialize = _fixture.Create <AttributeClass>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <SmallerAttributeClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.StringProperty, deserialized.StringProperty); Assert.Equal(toSerialize.NullableIntProperty, deserialized.NullableIntProperty); }
public void Avro2Json_ConvertDateTime_ProducedDesiredJson() { //Arrange var testObject = new DateTime(2022, 06, 13, 2, 0, 0, DateTimeKind.Utc); var expectedJson = JsonConvert.SerializeObject(testObject); var avroSerialized = AvroConvert.Serialize(testObject); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Component_ObjectContainsEmptyList_ResultIsTheSameAsInput() { //Arrange ClassWithConstructorPopulatingProperty testClass = new ClassWithConstructorPopulatingProperty(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithConstructorPopulatingProperty>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass, deserialized); }
public void Avro2Json_ConvertArray_ProducedDesiredJson() { //Arrange var arrayTestObject = new int[] { 2, 1, 3, 7, 453, 1, 6, }; var expectedJson = JsonConvert.SerializeObject(arrayTestObject); var avroSerialized = AvroConvert.Serialize(arrayTestObject); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Component_ObjectContainsArray_ResultIsTheSameAsInput() { //Arrange ClassWithArray testClass = _fixture.Create <ClassWithArray>(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithArray>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass.theArray.Length, deserialized.theArray.Length); }
public void Avro2Json_ConvertInt_ProducedDesiredJson() { //Arrange var @int = 2137; var expectedJson = JsonConvert.SerializeObject(@int); var avroSerialized = AvroConvert.Serialize(@int); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Brotli_SerializeAndDeserializeComplexClass_NoError() { //Arrange ExtendedBaseTestClass toSerialize = _fixture.Create <ExtendedBaseTestClass>(); //Act var result = AvroConvert.Serialize(toSerialize, CodecType.Brotli); var deserialized = AvroConvert.Deserialize <ExtendedBaseTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize, deserialized); }
public void Avro2Json_ConvertDouble_ProducedDesiredJson() { //Arrange var doubleTestObject = 21.34; var expectedJson = JsonConvert.SerializeObject(doubleTestObject); var avroSerialized = AvroConvert.Serialize(doubleTestObject); //Act var resultJson = AvroConvert.Avro2Json(avroSerialized); //Assert Assert.Equal(expectedJson, resultJson); }
public void Brotli_SerializeSmallerClassAndReadBigger_NoError() { //Arrange ReducedBaseTestClass toSerialize = _fixture.Create <ReducedBaseTestClass>(); //Act var result = AvroConvert.Serialize(toSerialize, CodecType.Brotli); var deserialized = AvroConvert.Deserialize <BaseTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.justSomeProperty, deserialized.justSomeProperty); }
public void Component_ClassWithoutGetters_ResultIsTheSameAsInput() { //Arrange ClassWithoutGetters toSerialize = _fixture.Create <ClassWithoutGetters>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <ClassWithoutGetters>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.Count, deserialized.Count); Assert.Equal(toSerialize.SomeString, deserialized.SomeString); }
public void Component_SerializeBiggerObjectAndReadSmaller_NoError() { //Arrange ExtendedBaseTestClass toSerialize = _fixture.Create <ExtendedBaseTestClass>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <BaseTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.justSomeProperty, deserialized.justSomeProperty); Assert.Equal(toSerialize.andLongProperty, deserialized.andLongProperty); }
public void Component_ObjectContainsComplexLists_ResultIsTheSameAsInput() { //Arrange ClassWithConstructorPopulatingProperty testClass = _fixture.Create <ClassWithConstructorPopulatingProperty>(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ClassWithConstructorPopulatingProperty>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass.nestedList.Count, deserialized.nestedList.Count); Assert.Equal(testClass.stringProperty, deserialized.stringProperty); Assert.Equal(testClass, deserialized); }
public void Component_ObjectContainsDictionaryAndMap_ResultIsTheSameAsInput() { //Arrange ExtendedBaseTestClass testClass = _fixture.Create <ExtendedBaseTestClass>(); //Act var result = AvroConvert.Serialize(testClass); var deserialized = AvroConvert.Deserialize <ExtendedBaseTestClass>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(testClass, deserialized); }
public async Task WriteToBlob( BlobContainerClient client, string blobName, object content) { var blob = client.GetBlobClient(blobName); if (_useCompression) { var serializedContent = AvroConvert.Serialize(content); await blob.UploadAsync(new BinaryData(serializedContent)); } else { await blob.UploadAsync(BinaryData.FromObjectAsJson(content)); } }
public void Component_EnumProperty_ResultIsTheSameAsInput() { //Arrange ClassWithEnum toSerialize = _fixture.Create <ClassWithEnum>(); //Act var result = AvroConvert.Serialize(toSerialize); var deserialized = AvroConvert.Deserialize <ClassWithEnum>(result); //Assert Assert.NotNull(result); Assert.NotNull(deserialized); Assert.Equal(toSerialize.EnumProp, deserialized.EnumProp); Assert.Equal(toSerialize, deserialized); }