Exemple #1
0
        public void ToJson_Generates_JsonString()
        {
            //Arrange
            var jsonHandling = new Infrastructure.JsonHandling.JsonHandling(_converter);

            //Act
            var result = jsonHandling.ToJson(GetPolicyOneClaims());
            var json   = JObject.Parse(result);

            //Assert
            result.ShouldNotBeNullOrWhiteSpace();
            result.ShouldContain("TestClaimId");
            (from p in json["claims"] select(string) p["claimId"])
            .FirstOrDefault()
            .ShouldBe("TestClaimId");
        }
Exemple #2
0
        public void FromJson_Generates_Object()
        {
            //Arrange
            var path         = Path.Combine(TestContext.CurrentContext.TestDirectory, "JsonHandling/JsonFiles/PolicyOneClaims.json");
            var json         = File.ReadAllText(path);
            var jsonHandling = new Infrastructure.JsonHandling.JsonHandling(_converter);

            //Act
            var result = jsonHandling.FromJson <PolicyOneClaims>(json);

            //Assert
            result.ShouldBeOfType(typeof(PolicyOneClaims));
            result.Claims.Count.ShouldBe(1);
            result.Claims[0].ClaimId.ShouldBe("TESTCLAIMID");
            result.Claims[0].Features.Count.ShouldBe(1);
            result.Claims[0].Features[0].ClaimFeatureId.ShouldBe("TESTCLAIMFEATUREID");
            result.Claims[0].Features[0].Payments.Count.ShouldBe(1);
            result.Claims[0].Features[0].Payments[0].PaymentId.ShouldBe("TESTPAYMENTID");
            result.Claims[0].Features[0].Reserves.Count.ShouldBe(1);
            result.Claims[0].Features[0].Reserves[0].ClaimReserveId.ShouldBe("TESTCLAIMRESERVEID");
        }