Exemplo n.º 1
0
        public void DeserializeTransformation()
        {
            var serializer = new RestClientSerializer();

            var actionId      = Guid.NewGuid();
            var stockId       = Guid.NewGuid();
            var resultStockId = Guid.NewGuid();
            var json          = "{\"id\":\"" + actionId + "\","
                                + "\"stock\":\"" + stockId + "\","
                                + "\"type\":\"transformation\","
                                + "\"actionDate\":\"2000-01-10\","
                                + "\"description\":\"description\","
                                + "\"implementationDate\":\"2000-02-01\","
                                + "\"cashComponent\":3.00,"
                                + "\"rolloverRefliefApplies\":true,"
                                + "\"resultingStocks\":["
                                + "{\"stock\":\"" + resultStockId + "\","
                                + "\"originalUnits\":1,"
                                + "\"newUnits\":2,"
                                + "\"costBase\":45.00,"
                                + "\"aquisitionDate\":\"2000-03-04\"}"
                                + "]}";

            var transaction = serializer.Deserialize <CorporateAction>(json);

            var expected = new Transformation()
            {
                Id                     = actionId,
                Stock                  = stockId,
                ActionDate             = new Date(2000, 01, 10),
                Description            = "description",
                ImplementationDate     = new Date(2000, 02, 01),
                CashComponent          = 3.00m,
                RolloverRefliefApplies = true
            };

            expected.AddResultingStock(resultStockId, 1, 2, 45.00m, new Date(2000, 03, 04));

            transaction.Should().BeEquivalentTo(expected);
        }