public SerializationTests(ITestOutputHelper testOutputHelper) { testOutputHelper_ = testOutputHelper; Console.SetOut(new TestOutputWriter(testOutputHelper_)); checklist_ = TestDataHelper.ConstructChecklist(); inspection_ = TestDataHelper.ConstructInspection(); farm_ = TestDataHelper.ConstructFarm(); }
void Can_compute_sha256_hash() { var inspection = TestDataHelper.ConstructInspection(); var checklist = TestDataHelper.ConstructChecklist(); var mandate = new Mandate(1, new[] { inspection }); var mergePackage = MergePackage.FromDomain(mandate, new[] { checklist }); var hash = JsonConvert.SerializeObject(mergePackage).ComputeSha256Hash(); hash.Should().NotBeEmpty(); hash.Length.Should().Be(64); }
void Can_prepare_merge_package() { // client end var inspection = TestDataHelper.ConstructInspection(); var checklist = TestDataHelper.ConstructChecklist(); var mandate = new Mandate(1, new[] { inspection }); var mergePackage = MergePackage.FromDomain(mandate, new[] { checklist, checklist }); string filename = Path.GetTempFileName() + ".json"; File.WriteAllText(filename, JsonConvert.SerializeObject(mergePackage)); // server end var receivedMergePackage = JsonConvert.DeserializeObject <MergePackage>(File.ReadAllText(filename)); receivedMergePackage.Should().NotBeNull(); var mandateOnServer = JsonConvert.DeserializeObject <MandateDeserializationDto>(receivedMergePackage.Mandate); mandateOnServer.Should().NotBeNull(); var checklistsOnServer = JsonConvert.DeserializeObject <ChecklistDeserializationDto[]>(receivedMergePackage.Checklists); checklistsOnServer.Should().NotBeNull(); checklistsOnServer.Length.Should().Be(2); }