public IEnumerator ObjectMapping_ShouldWork() { DocumentReference doc = TestDocument(); foreach (SerializationTestData.TestCase test in SerializationTestData.TestData( doc.Firestore)) { // Write input to `doc` via serialization SerializeToDoc(doc, test.Input); var getTask = doc.GetSnapshotAsync(Source.Cache); yield return(AwaitSuccess(getTask)); DocumentSnapshot docSnap = getTask.Result; // Read `doc` back via deserialization with both Firestore Types and input types object actualOutputWithRawFirestoreTypes, actualOutputWithInputTypes; DeserializeDoc(docSnap, test.Input, out actualOutputWithRawFirestoreTypes, out actualOutputWithInputTypes); Assert.That(actualOutputWithRawFirestoreTypes, Is.EqualTo(test.ExpectedRawOutput), "Deserialized value with Firestore Raw types does not match expected"); Assert.That(actualOutputWithInputTypes, Is.EqualTo(test.Input), "Deserialized value with input types does not match the input"); } }
public IEnumerator ObjectMapping_ShouldThrowForUnsupportedData() { DocumentReference doc = TestDocument(); foreach (SerializationTestData.TestCase test in SerializationTestData.UnsupportedTestData()) { object actualWithInputTypes; Assert.Throws(typeof(NotSupportedException), () => SerializeToDoc(doc, test.Input)); // Write the doc with expected output, then deserialize it back to input type. SerializeToDoc(doc, test.ExpectedRawOutput); Task <DocumentSnapshot> getTask = doc.GetSnapshotAsync(Source.Cache); yield return(AwaitSuccess(getTask)); var exception = Assert.Throws <TargetInvocationException>(() => { DeserializeWithInputTypes(getTask.Result, test.Input, out actualWithInputTypes); }); Assert.That(exception.InnerException, Is.TypeOf <NotSupportedException>()); } }
public IEnumerator ObjectMapping_ShouldThrowForUnsupportedReadToInputTypesData() { DocumentReference doc = TestDocument(); foreach (SerializationTestData.TestCase test in SerializationTestData .UnsupportedReadToInputTypesTestData()) { object actualWithFirestoreRawTypes, actualWithInputTypes; SerializeToDoc(doc, test.Input); Task <DocumentSnapshot> getTask = doc.GetSnapshotAsync(Source.Cache); yield return(AwaitSuccess(getTask)); DeserializeWithRawFirestoreTypes(getTask.Result, out actualWithFirestoreRawTypes); Assert.That(actualWithFirestoreRawTypes, Is.EqualTo(test.ExpectedRawOutput), "Deserialized value with Firestore Raw types does not match expected"); var exception = Assert.Throws <TargetInvocationException>(() => { DeserializeWithInputTypes(getTask.Result, test.Input, out actualWithInputTypes); }); Assert.That(exception.InnerException, Is.TypeOf <NotSupportedException>()); } }