public async Task <Result <MergeResult> > SendMergePackage(string uri, MergePackage mergePackage)
        {
            var payload = new Dictionary <string, string>
            {
                { nameof(MergePackage.Mandate), mergePackage.Mandate },
                { nameof(MergePackage.Checklists), mergePackage.Checklists }
            };

            return(await PostWithTypedResponseAsync <MergeResult>(uri, payload));
        }
        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);
        }
Beispiel #3
0
        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);
        }