Example #1
0
        public static void Token_DeserializeGitHub_Test03()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":  ""DE"",
                           ""party_id"":      ""TNM"",
                           ""uid"":           ""bdf21bce-fc97-11e8-8eb2-f2801f1b9fd1"",
                           ""type"":          ""APP_USER"",
                           ""contract_id"":   ""DE8ACC12E46L89"",
                           ""issuer"":        ""TheNewMotion"",
                           ""valid"":           true,
                           ""whitelist"":     ""ALLOWED"",
                           ""last_updated"":  ""2018-12-10T17:16:15Z""
                         }";

            #endregion

            Assert.IsTrue(Token.TryParse(JSON, out Token parsedToken, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("DE"), parsedToken.CountryCode);
            Assert.AreEqual(Party_Id.Parse("TNM"), parsedToken.PartyId);
            Assert.AreEqual(Token_Id.Parse("bdf21bce-fc97-11e8-8eb2-f2801f1b9fd1"), parsedToken.Id);
            Assert.AreEqual(TokenTypes.APP_USER, parsedToken.Type);
            Assert.AreEqual(Contract_Id.Parse("DE8ACC12E46L89"), parsedToken.ContractId);
            Assert.AreEqual("TheNewMotion", parsedToken.Issuer);
            Assert.AreEqual(true, parsedToken.IsValid);
            Assert.AreEqual(WhitelistTypes.ALLOWED, parsedToken.WhitelistType);
            Assert.AreEqual(DateTime.Parse("2018-12-10T17:16:15Z").ToIso8601(), parsedToken.LastUpdated.ToIso8601());
        }
Example #2
0
        public static void Token_DeserializeGitHub_Test01()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":    ""DE"",
                           ""party_id"":        ""TNM"",
                           ""uid"":             ""012345678"",
                           ""type"":            ""RFID"",
                           ""contract_id"":     ""DE8ACC12E46L89"",
                           ""visual_number"":   ""DF000-2001-8999-1"",
                           ""issuer"":          ""TheNewMotion"",
                           ""group_id"":        ""DF000-2001-8999"",
                           ""valid"":             true,
                           ""whitelist"":       ""ALWAYS"",
                           ""last_updated"":    ""2015-06-29T22:39:09Z""
                         }";

            #endregion

            Assert.IsTrue(Token.TryParse(JSON, out Token parsedToken, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("DE"), parsedToken.CountryCode);
            Assert.AreEqual(Party_Id.Parse("TNM"), parsedToken.PartyId);
            Assert.AreEqual(Token_Id.Parse("012345678"), parsedToken.Id);
            Assert.AreEqual(TokenTypes.RFID, parsedToken.Type);
            Assert.AreEqual(Contract_Id.Parse("DE8ACC12E46L89"), parsedToken.ContractId);
            Assert.AreEqual("DF000-2001-8999-1", parsedToken.VisualNumber);
            Assert.AreEqual("TheNewMotion", parsedToken.Issuer);
            Assert.AreEqual(Group_Id.Parse("DF000-2001-8999"), parsedToken.GroupId);
            Assert.AreEqual(true, parsedToken.IsValid);
            Assert.AreEqual(WhitelistTypes.ALWAYS, parsedToken.WhitelistType);
            Assert.AreEqual(DateTime.Parse("2015-06-29T22:39:09Z").ToIso8601(), parsedToken.LastUpdated.ToIso8601());
        }
Example #3
0
        public static void Credentials_DeserializeGitHub_Test01()
        {
            #region Define JSON

            var JSON = @"{
                           ""token"": ""ebf3b399-779f-4497-9b9d-ac6ad3cc44d2"",
                           ""url"":   ""https://example.com/ocpi/versions/"",
                           ""roles"": [{
                               ""role"":         ""CPO"",
                               ""party_id"":     ""EXA"",
                               ""country_code"": ""NL"",
                               ""business_details"": {
                                   ""name"":     ""Example Operator""
                               }
                           }]
                         }";

            #endregion

            Assert.IsTrue(Credentials.TryParse(JSON, out Credentials parsedCredentials, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(AccessToken.Parse("ebf3b399-779f-4497-9b9d-ac6ad3cc44d2"), parsedCredentials.Token);
            Assert.AreEqual(URL.Parse("https://example.com/ocpi/versions/"), parsedCredentials.URL);
            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("EXA"), parsedCredentials.Roles.First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.First().Role);
            Assert.AreEqual("Example Operator", parsedCredentials.Roles.First().BusinessDetails.Name);
        }
Example #4
0
        public static void Token_SerializeDeserialize_Test01()
        {
            var Token1 = new Token(
                CountryCode.Parse("DE"),
                Party_Id.Parse("GEF"),
                Token_Id.Parse("Token0001"),
                TokenTypes.RFID,
                Contract_Id.Parse("0815"),
                "GraphDefined GmbH",
                true,
                WhitelistTypes.NEVER,
                "RFID:0815",
                Group_Id.Parse("G1234"),
                Languages.de,
                ProfileTypes.FAST,
                new EnergyContract(
                    "Stadtwerke Jena-Ost",
                    EnergyContract_Id.Parse("GDF012324")
                    ),
                DateTime.Parse("2020-09-21T00:00:00.000Z")
                );

            var JSON = Token1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("Token0001", JSON["uid"].Value <String>());
            Assert.AreEqual("RFID", JSON["type"].Value <String>());
            Assert.AreEqual("0815", JSON["contract_id"].Value <String>());
            Assert.AreEqual("RFID:0815", JSON["visual_number"].Value <String>());
            Assert.AreEqual("GraphDefined GmbH", JSON["issuer"].Value <String>());
            Assert.AreEqual("G1234", JSON["group_id"].Value <String>());
            Assert.AreEqual(true, JSON["valid"].Value <Boolean>());
            Assert.AreEqual("NEVER", JSON["whitelist"].Value <String>());
            Assert.AreEqual("de", JSON["language"].Value <String>());
            Assert.AreEqual("FAST", JSON["default_profile_type"].Value <String>());
            Assert.AreEqual("Stadtwerke Jena-Ost", JSON["energy_contract"]["supplier_name"].Value <String>());
            Assert.AreEqual("GDF012324", JSON["energy_contract"]["contract_id"].Value <String>());
            Assert.AreEqual("2020-09-21T00:00:00.000Z", JSON["last_updated"].Value <String>());

            Assert.IsTrue(Token.TryParse(JSON, out Token Token2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(Token1.CountryCode, Token2.CountryCode);
            Assert.AreEqual(Token1.PartyId, Token2.PartyId);
            Assert.AreEqual(Token1.Id, Token2.Id);
            Assert.AreEqual(Token1.Type, Token2.Type);
            Assert.AreEqual(Token1.ContractId, Token2.ContractId);
            Assert.AreEqual(Token1.Issuer, Token2.Issuer);
            Assert.AreEqual(Token1.IsValid, Token2.IsValid);
            Assert.AreEqual(Token1.WhitelistType, Token2.WhitelistType);
            Assert.AreEqual(Token1.VisualNumber, Token2.VisualNumber);
            Assert.AreEqual(Token1.GroupId, Token2.GroupId);
            Assert.AreEqual(Token1.UILanguage, Token2.UILanguage);
            Assert.AreEqual(Token1.DefaultProfile, Token2.DefaultProfile);
            Assert.AreEqual(Token1.EnergyContract, Token2.EnergyContract);
            Assert.AreEqual(Token1.LastUpdated.ToIso8601(), Token2.LastUpdated.ToIso8601());
        }
Example #5
0
        public static void Credentials_DeserializeGitHub_Test04()
        {
            #region Define JSON

            var JSON = @"{
                           ""token"":  ""9e80aca8-28be-11e9-b210-d663bd873d93"",
                           ""url"":    ""https://ocpi.example.com/versions/"",
                           ""roles"": [{
                               ""role"":         ""CPO"",
                               ""party_id"":     ""EXO"",
                               ""country_code"": ""NL"",
                               ""business_details"": {
                                   ""name"":     ""Excellent Operator""
                               }
                           }, {
                               ""role"":         ""CPO"",
                               ""party_id"":     ""PFC"",
                               ""country_code"": ""NL"",
                               ""business_details"": {
                                   ""name"":     ""Plug Flex Charging""
                               }
                           }, {
                               ""role"":         ""CPO"",
                               ""party_id"":     ""CGP"",
                               ""country_code"": ""NL"",
                               ""business_details"": {
                                   ""name"":     ""Charging Green Power""
                               }
                           }]
                         }";

            #endregion

            Assert.IsTrue(Credentials.TryParse(JSON, out Credentials parsedCredentials, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(AccessToken.Parse("9e80aca8-28be-11e9-b210-d663bd873d93"), parsedCredentials.Token);
            Assert.AreEqual(URL.Parse("https://ocpi.example.com/versions/"), parsedCredentials.URL);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("EXO"), parsedCredentials.Roles.First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.First().Role);
            Assert.AreEqual("Excellent Operator", parsedCredentials.Roles.First().BusinessDetails.Name);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.Skip(1).First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("PFC"), parsedCredentials.Roles.Skip(1).First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.Skip(1).First().Role);
            Assert.AreEqual("Plug Flex Charging", parsedCredentials.Roles.Skip(1).First().BusinessDetails.Name);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.Skip(2).First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("CGP"), parsedCredentials.Roles.Skip(2).First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.Skip(2).First().Role);
            Assert.AreEqual("Charging Green Power", parsedCredentials.Roles.Skip(2).First().BusinessDetails.Name);
        }
Example #6
0
        public static void Session_DeserializeGitHub_Test01()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":    ""NL"",
                           ""party_id"":        ""STK"",
                           ""id"":              ""101"",
                           ""start_date_time"": ""2020-03-09T10:17:09Z"",
                           ""kwh"":               0.0,
                           ""cdr_token"": {
                               ""uid"":         ""123abc"",
                               ""type"":        ""RFID"",
                               ""contract_id"": ""NL-TST-C12345678-S""
                           },
                           ""auth_method"":     ""WHITELIST"",
                           ""location_id"":     ""LOC1"",
                           ""evse_uid"":        ""3256"",
                           ""connector_id"":    ""1"",
                           ""currency"":        ""EUR"",
                           ""total_cost"": {
                               ""excl_vat"":      2.5
                           },
                           ""status"":          ""PENDING"",
                           ""last_updated"":    ""2020-03-09T10:17:09Z""
                         }";

            #endregion

            Assert.IsTrue(Session.TryParse(JSON, out Session parsedSession, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedSession.CountryCode);
            Assert.AreEqual(Party_Id.Parse("STK"), parsedSession.PartyId);
            Assert.AreEqual(Session_Id.Parse("101"), parsedSession.Id);
            //Assert.AreEqual(Session1.Start.    ToIso8601(),    parsedSession.Start.    ToIso8601());
            //Assert.AreEqual(Session1.End.Value.ToIso8601(),    parsedSession.End.Value.ToIso8601());
            //Assert.AreEqual(Session1.kWh,                      parsedSession.kWh);
            //Assert.AreEqual(Session1.CDRToken,                 parsedSession.CDRToken);
            //Assert.AreEqual(Session1.AuthMethod,               parsedSession.AuthMethod);
            //Assert.AreEqual(Session1.AuthorizationReference,   parsedSession.AuthorizationReference);
            //Assert.AreEqual(Session1.LocationId,               parsedSession.LocationId);
            //Assert.AreEqual(Session1.EVSEUId,                  parsedSession.EVSEUId);
            //Assert.AreEqual(Session1.ConnectorId,              parsedSession.ConnectorId);
            //Assert.AreEqual(Session1.MeterId,                  parsedSession.MeterId);
            //Assert.AreEqual(Session1.EnergyMeter,              parsedSession.EnergyMeter);
            //Assert.AreEqual(Session1.TransparencySoftwares,    parsedSession.TransparencySoftwares);
            //Assert.AreEqual(Session1.Currency,                 parsedSession.Currency);
            //Assert.AreEqual(Session1.ChargingPeriods,          parsedSession.ChargingPeriods);
            //Assert.AreEqual(Session1.TotalCosts,               parsedSession.TotalCosts);
            //Assert.AreEqual(Session1.Status,                   parsedSession.Status);
            //Assert.AreEqual(Session1.LastUpdated.ToIso8601(),  parsedSession.LastUpdated.ToIso8601());
        }
Example #7
0
        public static void Token_DeserializeGitHub_Test02()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":          ""DE"",
                           ""party_id"":              ""TNM"",
                           ""uid"":                   ""12345678905880"",
                           ""type"":                  ""RFID"",
                           ""contract_id"":           ""DE8ACC12E46L89"",
                           ""visual_number"":         ""DF000-2001-8999-1"",
                           ""issuer"":                ""TheNewMotion"",
                           ""group_id"":              ""DF000-2001-8999"",
                           ""valid"":                   true,
                           ""whitelist"":             ""ALLOWED"",
                           ""language"":              ""it"",
                           ""default_profile_type"":  ""GREEN"",
                           ""energy_contract"": {
                             ""supplier_name"":       ""Greenpeace Energy eG"",
                             ""contract_id"":         ""0123456789""
                           },
                           ""last_updated"":          ""2018-12-10T17:25:10Z""
                         }";

            #endregion

            Assert.IsTrue(Token.TryParse(JSON, out Token parsedToken, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("DE"), parsedToken.CountryCode);
            Assert.AreEqual(Party_Id.Parse("TNM"), parsedToken.PartyId);
            Assert.AreEqual(Token_Id.Parse("12345678905880"), parsedToken.Id);
            Assert.AreEqual(TokenTypes.RFID, parsedToken.Type);
            Assert.AreEqual(Contract_Id.Parse("DE8ACC12E46L89"), parsedToken.ContractId);
            Assert.AreEqual("DF000-2001-8999-1", parsedToken.VisualNumber);
            Assert.AreEqual("TheNewMotion", parsedToken.Issuer);
            Assert.AreEqual(Group_Id.Parse("DF000-2001-8999"), parsedToken.GroupId);
            Assert.AreEqual(true, parsedToken.IsValid);
            Assert.AreEqual(WhitelistTypes.ALLOWED, parsedToken.WhitelistType);
            Assert.AreEqual(Languages.it, parsedToken.UILanguage);
            Assert.AreEqual(ProfileTypes.GREEN, parsedToken.DefaultProfile);
            Assert.AreEqual("Greenpeace Energy eG", parsedToken.EnergyContract.Value.SupplierName);
            Assert.AreEqual(EnergyContract_Id.Parse("0123456789"), parsedToken.EnergyContract.Value.ContractId);
            Assert.AreEqual(DateTime.Parse("2018-12-10T17:25:10Z").ToIso8601(), parsedToken.LastUpdated.ToIso8601());
        }
Example #8
0
        public static void Credentials_DeserializeGitHub_Test03()
        {
            #region Define JSON

            var JSON = @"{
                           ""token"":  ""9e80ae10-28be-11e9-b210-d663bd873d93"",
                           ""url"":    ""https://example.com/ocpi/versions/"",
                           ""roles"": [{
                               ""role"":              ""CPO"",
                               ""party_id"":          ""EXA"",
                               ""country_code"":      ""NL"",
                               ""business_details"": {
                                   ""name"":          ""Example Operator"",
                                   ""logo"": {
                                       ""url"":       ""https://example.com/img/logo.jpg"",
                                       ""thumbnail"": ""https://example.com/img/logo_thumb.jpg"",
                                       ""category"":  ""OPERATOR"",
                                       ""type"":      ""jpeg"",
                                       ""width"":     512,
                                       ""height"":    512
                                   },
                                   ""website"":       ""http://example.com""
                               }
                           }]
                         }";

            #endregion

            Assert.IsTrue(Credentials.TryParse(JSON, out Credentials parsedCredentials, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(AccessToken.Parse("9e80ae10-28be-11e9-b210-d663bd873d93"), parsedCredentials.Token);
            Assert.AreEqual(URL.Parse("https://example.com/ocpi/versions/"), parsedCredentials.URL);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("EXA"), parsedCredentials.Roles.First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.First().Role);
            Assert.AreEqual(URL.Parse("https://example.com/img/logo.jpg"), parsedCredentials.Roles.First().BusinessDetails.Logo.URL);
            Assert.AreEqual(URL.Parse("https://example.com/img/logo_thumb.jpg"), parsedCredentials.Roles.First().BusinessDetails.Logo.Thumbnail);
            Assert.AreEqual(ImageCategories.OPERATOR, parsedCredentials.Roles.First().BusinessDetails.Logo.Category);
            Assert.AreEqual(ImageFileType.jpeg, parsedCredentials.Roles.First().BusinessDetails.Logo.Type);
            Assert.AreEqual(512, parsedCredentials.Roles.First().BusinessDetails.Logo.Width);
            Assert.AreEqual(512, parsedCredentials.Roles.First().BusinessDetails.Logo.Height);
            Assert.AreEqual(URL.Parse("http://example.com"), parsedCredentials.Roles.First().BusinessDetails.Website);
        }
Example #9
0
        public static void Credentials_DeserializeGitHub_Test02()
        {
            #region Define JSON

            var JSON = @"{
                           ""token"":  ""9e80a9c4-28be-11e9-b210-d663bd873d93"",
                           ""url"":    ""https://ocpi.example.com/versions/"",
                           ""roles"": [{
                               ""role"":          ""CPO"",
                               ""party_id"":      ""EXA"",
                               ""country_code"":  ""NL"",
                               ""business_details"": {
                                   ""name"":      ""Example Operator""
                               }
                           }, {
                               ""role"":          ""EMSP"",
                               ""party_id"":      ""EXA"",
                               ""country_code"":  ""NL"",
                               ""business_details"": {
                                   ""name"":      ""Example Provider""
                               }
                           }]
                         }";

            #endregion

            Assert.IsTrue(Credentials.TryParse(JSON, out Credentials parsedCredentials, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(AccessToken.Parse("9e80a9c4-28be-11e9-b210-d663bd873d93"), parsedCredentials.Token);
            Assert.AreEqual(URL.Parse("https://ocpi.example.com/versions/"), parsedCredentials.URL);

            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("EXA"), parsedCredentials.Roles.First().PartyId);
            Assert.AreEqual(Roles.CPO, parsedCredentials.Roles.First().Role);
            Assert.AreEqual("Example Operator", parsedCredentials.Roles.First().BusinessDetails.Name);

            // Note: Same CountryCode and PartyId, but different roles: Is this really a good idea?
            Assert.AreEqual(CountryCode.Parse("NL"), parsedCredentials.Roles.Skip(1).First().CountryCode);
            Assert.AreEqual(Party_Id.Parse("EXA"), parsedCredentials.Roles.Skip(1).First().PartyId);
            Assert.AreEqual(Roles.EMSP, parsedCredentials.Roles.Skip(1).First().Role);
            Assert.AreEqual("Example Provider", parsedCredentials.Roles.Skip(1).First().BusinessDetails.Name);
        }
Example #10
0
        public static void Session_SerializeDeserialize_Test01()
        {
            #region Define Session1

            var Session1 = new Session(
                CountryCode.Parse("DE"),
                Party_Id.Parse("GEF"),
                Session_Id.Parse("Session0001"),
                DateTime.Parse("2020-08-21T00:00:00.000Z"), // Start
                1.11M,                                      // KWh
                new CDRToken(
                    Token_Id.Parse("1234"),
                    TokenTypes.RFID,
                    Contract_Id.Parse("Contract0815")
                    ),
                AuthMethods.AUTH_REQUEST,
                Location_Id.Parse("LOC0001"),
                EVSE_UId.Parse("EVSE0001"),
                Connector_Id.Parse("C1"),
                Currency.EUR,
                SessionStatusTypes.ACTIVE,
                DateTime.Parse("2020-08-22T00:00:00.000Z"),                // End
                AuthorizationReference.Parse("Auth1234"),

                Meter_Id.Parse("Meter0001"),

                // OCPI Computer Science Extentions
                new EnergyMeter(
                    Meter_Id.Parse("Meter0815"),
                    "EnergyMeter Model #1",
                    "hw. v1.80",
                    "fw. v1.20",
                    "Energy Metering Services",
                    null,
                    null
                    ),

                // OCPI Computer Science Extentions
                new TransparencySoftware[] {
                new TransparencySoftware(
                    "Chargy Transparency Software Desktop Application",
                    "v1.00",
                    LegalStatus.LegallyBinding,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyDesktopApp")
                    ),
                new TransparencySoftware(
                    "Chargy Transparency Software Mobile Application",
                    "v1.00",
                    LegalStatus.ForInformationOnly,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyMobileApp")
                    )
            },

                new ChargingPeriod[] {
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:49Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.ENERGY,
                        1.33M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0001")
                    ),
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:50Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.TIME,
                        5.12M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0002")
                    )
            },

                // Total Costs
                new Price(
                    1.12,
                    2.24
                    ),

                DateTime.Parse("2020-09-21T00:00:00.000Z")
                );

            #endregion

            var JSON = Session1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("Session0001", JSON["id"].Value <String>());
            Assert.AreEqual("2020-08-21T00:00:00.000Z", JSON["start_date_time"].Value <String>());
            Assert.AreEqual("2020-08-22T00:00:00.000Z", JSON["end_date_time"].Value <String>());
            Assert.AreEqual(1.11, JSON["kwh"].Value <Decimal>());
            Assert.AreEqual("1234", JSON["cdr_token"]["uid"].Value <String>());
            Assert.AreEqual("RFID", JSON["cdr_token"]["type"].Value <String>());
            Assert.AreEqual("Contract0815", JSON["cdr_token"]["contract_id"].Value <String>());
            Assert.AreEqual("AUTH_REQUEST", JSON["auth_method"].Value <String>());
            Assert.AreEqual("Auth1234", JSON["authorization_reference"].Value <String>());
            Assert.AreEqual("LOC0001", JSON["location_id"].Value <String>());
            Assert.AreEqual("EVSE0001", JSON["evse_uid"].Value <String>());
            Assert.AreEqual("C1", JSON["connector_id"].Value <String>());
            Assert.AreEqual("Meter0001", JSON["meter_id"].Value <String>());
            Assert.AreEqual("EUR", JSON["currency"].Value <String>());
            //Assert.AreEqual("Stadtwerke Jena-Ost",             JSON["charging_periods"]["xxx"].Value<String>());
            Assert.AreEqual(1.12, JSON["total_cost"]["excl_vat"].Value <Decimal>());
            Assert.AreEqual(2.24, JSON["total_cost"]["incl_vat"].Value <Decimal>());
            Assert.AreEqual("ACTIVE", JSON["status"].Value <String>());
            Assert.AreEqual("2020-09-21T00:00:00.000Z", JSON["last_updated"].Value <String>());

            Assert.IsTrue(Session.TryParse(JSON, out Session Session2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(Session1.CountryCode, Session2.CountryCode);
            Assert.AreEqual(Session1.PartyId, Session2.PartyId);
            Assert.AreEqual(Session1.Id, Session2.Id);
            Assert.AreEqual(Session1.Start.ToIso8601(), Session2.Start.ToIso8601());
            Assert.AreEqual(Session1.End.Value.ToIso8601(), Session2.End.Value.ToIso8601());
            Assert.AreEqual(Session1.kWh, Session2.kWh);
            Assert.AreEqual(Session1.CDRToken, Session2.CDRToken);
            Assert.AreEqual(Session1.AuthMethod, Session2.AuthMethod);
            Assert.AreEqual(Session1.AuthorizationReference, Session2.AuthorizationReference);
            Assert.AreEqual(Session1.LocationId, Session2.LocationId);
            Assert.AreEqual(Session1.EVSEUId, Session2.EVSEUId);
            Assert.AreEqual(Session1.ConnectorId, Session2.ConnectorId);
            Assert.AreEqual(Session1.MeterId, Session2.MeterId);
            Assert.AreEqual(Session1.EnergyMeter, Session2.EnergyMeter);
            Assert.AreEqual(Session1.TransparencySoftwares, Session2.TransparencySoftwares);
            Assert.AreEqual(Session1.Currency, Session2.Currency);
            Assert.AreEqual(Session1.ChargingPeriods, Session2.ChargingPeriods);
            Assert.AreEqual(Session1.TotalCosts, Session2.TotalCosts);
            Assert.AreEqual(Session1.Status, Session2.Status);
            Assert.AreEqual(Session1.LastUpdated.ToIso8601(), Session2.LastUpdated.ToIso8601());
        }
Example #11
0
        public static void Session_DeserializeGitHub_Test02()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":        ""BE"",
                           ""party_id"":            ""BEC"",
                           ""id"":                  ""101"",
                           ""start_date_time"":     ""2015-06-29T22:39:09Z"",
                           ""end_date_time"":       ""2015-06-29T23:50:16Z"",
                           ""kwh"": 41.00,
                            ""cdr_token"": {
                                 ""uid"":           ""123abc"",
                                 ""type"":          ""RFID"",
                                 ""contract_id"":   ""NL-TST-C12345678-S""
                             },
                           ""auth_method"":         ""WHITELIST"",
                           ""location_id"":         ""LOC1"",
                           ""evse_uid"":            ""3256"",
                           ""connector_id"":        ""1"",
                           ""currency"":            ""EUR"",
                           ""charging_periods"": [{
                             ""start_date_time"":   ""2015-06-29T22:39:09Z"",
                             ""dimensions"": [{
                               ""type"":            ""ENERGY"",
                               ""volume"":            120
                             }, {
                               ""type"":            ""MAX_CURRENT"",
                               ""volume"":            30
                             }]
                           }, {
                             ""start_date_time"":   ""2015-06-29T22:40:54Z"",
                             ""dimensions"": [{
                               ""type"":            ""ENERGY"",
                               ""volume"":            41000
                             }, {
                               ""type"":            ""MIN_CURRENT"",
                               ""volume"":            34
                             }]
                           }, {
                             ""start_date_time"":   ""2015-06-29T23:07:09Z"",
                             ""dimensions"": [{
                               ""type"":            ""PARKING_TIME"",
                               ""volume"":            0.718
                             }],
                             ""tariff_id"":         ""12""
                           }],
                           ""total_cost"": {
                             ""excl_vat"":            8.50,
                             ""incl_vat"":            9.35
                           },
                           ""status"":              ""COMPLETED"",
                           ""last_updated"":        ""2015-06-29T23:50:17Z""
                         }";

            #endregion

            Assert.IsTrue(Session.TryParse(JSON, out Session parsedSession, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("BE"), parsedSession.CountryCode);
            Assert.AreEqual(Party_Id.Parse("BEC"), parsedSession.PartyId);
            Assert.AreEqual(Session_Id.Parse("101"), parsedSession.Id);
            //Assert.AreEqual(Session1.Start.    ToIso8601(),    parsedSession.Start.    ToIso8601());
            //Assert.AreEqual(Session1.End.Value.ToIso8601(),    parsedSession.End.Value.ToIso8601());
            //Assert.AreEqual(Session1.kWh,                      parsedSession.kWh);
            //Assert.AreEqual(Session1.CDRToken,                 parsedSession.CDRToken);
            //Assert.AreEqual(Session1.AuthMethod,               parsedSession.AuthMethod);
            //Assert.AreEqual(Session1.AuthorizationReference,   parsedSession.AuthorizationReference);
            //Assert.AreEqual(Session1.LocationId,               parsedSession.LocationId);
            //Assert.AreEqual(Session1.EVSEUId,                  parsedSession.EVSEUId);
            //Assert.AreEqual(Session1.ConnectorId,              parsedSession.ConnectorId);
            //Assert.AreEqual(Session1.MeterId,                  parsedSession.MeterId);
            //Assert.AreEqual(Session1.EnergyMeter,              parsedSession.EnergyMeter);
            //Assert.AreEqual(Session1.TransparencySoftwares,    parsedSession.TransparencySoftwares);
            //Assert.AreEqual(Session1.Currency,                 parsedSession.Currency);
            //Assert.AreEqual(Session1.ChargingPeriods,          parsedSession.ChargingPeriods);
            //Assert.AreEqual(Session1.TotalCosts,               parsedSession.TotalCosts);
            //Assert.AreEqual(Session1.Status,                   parsedSession.Status);
            //Assert.AreEqual(Session1.LastUpdated.ToIso8601(),  parsedSession.LastUpdated.ToIso8601());
        }
Example #12
0
        public static void Tariff_SerializeDeserialize_Test01()
        {
            var TariffA = new Tariff(
                CountryCode.Parse("DE"),
                Party_Id.Parse("GEF"),
                Tariff_Id.Parse("TARIFF0001"),
                Currency.EUR,
                new TariffElement[] {
                new TariffElement(
                    new PriceComponent[] {
                    PriceComponent.ChargingTime(
                        TimeSpan.FromSeconds(300),
                        2.00M,
                        0.10M
                        )
                },
                    new TariffRestrictions [] {
                    new TariffRestrictions(
                        Time.FromHourMin(08, 00),                            // Start time
                        Time.FromHourMin(18, 00),                            // End time
                        DateTime.Parse("2020-12-01"),                        // Start timestamp
                        DateTime.Parse("2020-12-31"),                        // End timestamp
                        1.12M,                                               // MinkWh
                        5.67M,                                               // MaxkWh
                        1.34M,                                               // MinCurrent
                        8.89M,                                               // MaxCurrent
                        1.49M,                                               // MinPower
                        9.91M,                                               // MaxPower
                        TimeSpan.FromMinutes(10),                            // MinDuration
                        TimeSpan.FromMinutes(30),                            // MaxDuration
                        new DayOfWeek[] {
                        DayOfWeek.Monday,
                        DayOfWeek.Tuesday
                    },
                        ReservationRestrictionTypes.RESERVATION
                        )
                }
                    )
            },
                TariffTypes.PROFILE_GREEN,
                new DisplayText[] {
                new DisplayText(Languages.de, "Hallo Welt!"),
                new DisplayText(Languages.en, "Hello world!"),
            },
                URL.Parse("https://open.charging.cloud"),
                new Price(               // Min Price
                    1.10,
                    1.26
                    ),
                new Price(               // Max Price
                    2.20,
                    2.52
                    ),
                DateTime.Parse("2020-12-01"),               // Start timestamp
                DateTime.Parse("2020-12-31"),               // End timestamp
                new EnergyMix(
                    true,
                    new EnergySource[] {
                new EnergySource(
                    EnergySourceCategories.SOLAR,
                    80
                    ),
                new EnergySource(
                    EnergySourceCategories.WIND,
                    20
                    )
            },
                    new EnvironmentalImpact[] {
                new EnvironmentalImpact(
                    EnvironmentalImpactCategories.CARBON_DIOXIDE,
                    0.1
                    )
            },
                    "Stadtwerke Jena-Ost",
                    "New Green Deal"
                    ),
                DateTime.Parse("2020-09-22")
                );

            var JSON = TariffA.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("TARIFF0001", JSON["id"].Value <String>());

            Assert.IsTrue(Tariff.TryParse(JSON, out Tariff TariffB, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(TariffA.CountryCode, TariffB.CountryCode);
            Assert.AreEqual(TariffA.PartyId, TariffB.PartyId);
            Assert.AreEqual(TariffA.Id, TariffB.Id);
            Assert.AreEqual(TariffA.Currency, TariffB.Currency);
            Assert.AreEqual(TariffA.TariffElements, TariffB.TariffElements);

            Assert.AreEqual(TariffA.TariffType, TariffB.TariffType);
            Assert.AreEqual(TariffA.TariffAltText, TariffB.TariffAltText);
            Assert.AreEqual(TariffA.TariffAltURL, TariffB.TariffAltURL);
            Assert.AreEqual(TariffA.MinPrice, TariffB.MinPrice);
            Assert.AreEqual(TariffA.MaxPrice, TariffB.MaxPrice);
            Assert.AreEqual(TariffA.Start, TariffB.Start);
            Assert.AreEqual(TariffA.End, TariffB.End);
            Assert.AreEqual(TariffA.EnergyMix, TariffB.EnergyMix);

            Assert.AreEqual(TariffA.LastUpdated.ToIso8601(), TariffB.LastUpdated.ToIso8601());
        }
Example #13
0
        public static void Credentials_SerializeDeserialize_Test01()
        {
            #region Defined Credentials1

            var Credentials1 = new Credentials(

                AccessToken.Parse("4285n43805fng38"),
                URL.Parse("http://open.charging.cloud/versions"),

                new CredentialsRole[] {
                new CredentialsRole(
                    CountryCode.Parse("DE"),
                    Party_Id.Parse("GEF"),
                    Roles.CPO,
                    new BusinessDetails(
                        "Open Charging Cloud CPO",
                        URL.Parse("http://cpo.charging.cloud"),
                        new Image(
                            URL.Parse("http://cpo.charging.cloud/logo"),
                            ImageFileType.svg,
                            ImageCategories.OPERATOR,
                            1000,
                            1500,
                            URL.Parse("http://cpo.charging.cloud/logo_small")
                            )
                        )
                    ),

                new CredentialsRole(
                    CountryCode.Parse("DE"),
                    Party_Id.Parse("GDF"),
                    Roles.EMSP,
                    new BusinessDetails(
                        "Open Charging Cloud EMSP",
                        URL.Parse("http://emsp.charging.cloud"),
                        new Image(
                            URL.Parse("http://emsp.charging.cloud/logo"),
                            ImageFileType.png,
                            ImageCategories.NETWORK,
                            2000,
                            3000,
                            URL.Parse("http://emsp.charging.cloud/logo_small")
                            )
                        )
                    )
            }
                );

            #endregion

            var JSON = Credentials1.ToJSON();

            Assert.AreEqual("4285n43805fng38", JSON["token"].Value <String>());
            Assert.AreEqual("http://open.charging.cloud/versions", JSON["url"].Value <String>());

            Assert.AreEqual("DE", JSON["roles"][0]["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["roles"][0]["party_id"].Value <String>());
            Assert.AreEqual("CPO", JSON["roles"][0]["role"].Value <String>());
            Assert.AreEqual("Open Charging Cloud CPO", JSON["roles"][0]["business_details"]["name"].Value <String>());
            Assert.AreEqual("http://cpo.charging.cloud", JSON["roles"][0]["business_details"]["website"].Value <String>());
            Assert.AreEqual("http://cpo.charging.cloud/logo", JSON["roles"][0]["business_details"]["logo"]["url"].Value <String>());
            Assert.AreEqual("http://cpo.charging.cloud/logo_small", JSON["roles"][0]["business_details"]["logo"]["thumbnail"].Value <String>());
            Assert.AreEqual("OPERATOR", JSON["roles"][0]["business_details"]["logo"]["category"].Value <String>());
            Assert.AreEqual("svg", JSON["roles"][0]["business_details"]["logo"]["type"].Value <String>());
            Assert.AreEqual(1000, JSON["roles"][0]["business_details"]["logo"]["width"].Value <UInt16>());
            Assert.AreEqual(1500, JSON["roles"][0]["business_details"]["logo"]["height"].Value <UInt16>());

            Assert.AreEqual("DE", JSON["roles"][1]["country_code"].Value <String>());
            Assert.AreEqual("GDF", JSON["roles"][1]["party_id"].Value <String>());
            Assert.AreEqual("EMSP", JSON["roles"][1]["role"].Value <String>());
            Assert.AreEqual("Open Charging Cloud EMSP", JSON["roles"][1]["business_details"]["name"].Value <String>());
            Assert.AreEqual("http://emsp.charging.cloud", JSON["roles"][1]["business_details"]["website"].Value <String>());
            Assert.AreEqual("http://emsp.charging.cloud/logo", JSON["roles"][1]["business_details"]["logo"]["url"].Value <String>());
            Assert.AreEqual("http://emsp.charging.cloud/logo_small", JSON["roles"][1]["business_details"]["logo"]["thumbnail"].Value <String>());
            Assert.AreEqual("NETWORK", JSON["roles"][1]["business_details"]["logo"]["category"].Value <String>());
            Assert.AreEqual("png", JSON["roles"][1]["business_details"]["logo"]["type"].Value <String>());
            Assert.AreEqual(2000, JSON["roles"][1]["business_details"]["logo"]["width"].Value <UInt16>());
            Assert.AreEqual(3000, JSON["roles"][1]["business_details"]["logo"]["height"].Value <UInt16>());


            Assert.IsTrue(Credentials.TryParse(JSON, out Credentials Credentials2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(Credentials1.Token, Credentials2.Token);
            Assert.AreEqual(Credentials1.URL, Credentials2.URL);
            Assert.AreEqual(Credentials1.Roles, Credentials2.Roles);
        }
Example #14
0
        public static void CDR_SerializeDeserialize_Test01()
        {
            #region Defined CDR1

            var CDR1 = new CDR(CountryCode.Parse("DE"),
                               Party_Id.Parse("GEF"),
                               CDR_Id.Parse("CDR0001"),
                               DateTime.Parse("2020-04-12T18:20:19Z"),
                               DateTime.Parse("2020-04-12T22:20:19Z"),
                               new CDRToken(
                                   Token_Id.Parse("1234"),
                                   TokenTypes.RFID,
                                   Contract_Id.Parse("C1234")
                                   ),
                               AuthMethods.AUTH_REQUEST,
                               new CDRLocation(
                                   Location_Id.Parse("LOC0001"),
                                   "Biberweg 18",
                                   "Jena",
                                   "Deutschland",
                                   GeoCoordinate.Parse(10, 20),
                                   EVSE_UId.Parse("DE*GEF*E*LOC0001*1"),
                                   EVSE_Id.Parse("DE*GEF*E*LOC0001*1"),
                                   Connector_Id.Parse("1"),
                                   ConnectorTypes.IEC_62196_T2,
                                   ConnectorFormats.SOCKET,
                                   PowerTypes.AC_3_PHASE,
                                   "Name?",
                                   "07749"
                                   ),
                               Currency.EUR,

                               new ChargingPeriod[] {
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:49Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.ENERGY,
                        1.33M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0001")
                    ),
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:50Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.TIME,
                        5.12M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0002")
                    )
            },

                               // Total costs
                               new Price(
                                   10.00,
                                   11.60
                                   ),

                               // Total Energy
                               50.00M,

                               // Total time
                               TimeSpan.FromMinutes(30),

                               Session_Id.Parse("0815"),
                               AuthorizationReference.Parse("Auth0815"),
                               Meter_Id.Parse("Meter0815"),

                               // OCPI Computer Science Extentions
                               new EnergyMeter(
                                   Meter_Id.Parse("Meter0815"),
                                   "EnergyMeter Model #1",
                                   "hw. v1.80",
                                   "fw. v1.20",
                                   "Energy Metering Services",
                                   null,
                                   null
                                   ),

                               // OCPI Computer Science Extentions
                               new TransparencySoftware[] {
                new TransparencySoftware(
                    "Chargy Transparency Software Desktop Application",
                    "v1.00",
                    LegalStatus.LegallyBinding,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyDesktopApp")
                    ),
                new TransparencySoftware(
                    "Chargy Transparency Software Mobile Application",
                    "v1.00",
                    LegalStatus.ForInformationOnly,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyMobileApp")
                    )
            },

                               new Tariff[] {
                new Tariff(
                    CountryCode.Parse("DE"),
                    Party_Id.Parse("GEF"),
                    Tariff_Id.Parse("TARIFF0001"),
                    Currency.EUR,
                    new TariffElement[] {
                    new TariffElement(
                        new PriceComponent[] {
                        PriceComponent.ChargingTime(
                            TimeSpan.FromSeconds(300),
                            2.00M,
                            0.10M
                            )
                    },
                        new TariffRestrictions [] {
                        new TariffRestrictions(
                            Time.FromHourMin(08, 00),                                 // Start time
                            Time.FromHourMin(18, 00),                                 // End time
                            DateTime.Parse("2020-12-01"),                             // Start timestamp
                            DateTime.Parse("2020-12-31"),                             // End timestamp
                            1.12M,                                                    // MinkWh
                            5.67M,                                                    // MaxkWh
                            1.34M,                                                    // MinCurrent
                            8.89M,                                                    // MaxCurrent
                            1.49M,                                                    // MinPower
                            9.91M,                                                    // MaxPower
                            TimeSpan.FromMinutes(10),                                 // MinDuration
                            TimeSpan.FromMinutes(30),                                 // MaxDuration
                            new DayOfWeek[] {
                            DayOfWeek.Monday,
                            DayOfWeek.Tuesday
                        },
                            ReservationRestrictionTypes.RESERVATION
                            )
                    }
                        )
                },
                    TariffTypes.PROFILE_GREEN,
                    new DisplayText[] {
                    new DisplayText(Languages.de, "Hallo Welt!"),
                    new DisplayText(Languages.en, "Hello world!"),
                },
                    URL.Parse("https://open.charging.cloud"),
                    new Price(                    // Min Price
                        1.10,
                        1.26
                        ),
                    new Price(                    // Max Price
                        2.20,
                        2.52
                        ),
                    DateTime.Parse("2020-12-01"),                    // Start timestamp
                    DateTime.Parse("2020-12-31"),                    // End timestamp
                    new EnergyMix(
                        true,
                        new EnergySource[] {
                    new EnergySource(
                        EnergySourceCategories.SOLAR,
                        80
                        ),
                    new EnergySource(
                        EnergySourceCategories.WIND,
                        20
                        )
                },
                        new EnvironmentalImpact[] {
                    new EnvironmentalImpact(
                        EnvironmentalImpactCategories.CARBON_DIOXIDE,
                        0.1
                        )
                },
                        "Stadtwerke Jena-Ost",
                        "New Green Deal"
                        ),
                    DateTime.Parse("2020-09-22")
                    )
            },

                               new SignedData(
                                   EncodingMethod.GraphDefiened,
                                   new SignedValue[] {
                new SignedValue(
                    SignedValueNature.START,
                    "PlainStartValue",
                    "SignedStartValue"
                    ),
                new SignedValue(
                    SignedValueNature.INTERMEDIATE,
                    "PlainIntermediateValue",
                    "SignedIntermediateValue"
                    ),
                new SignedValue(
                    SignedValueNature.END,
                    "PlainEndValue",
                    "SignedEndValue"
                    )
            },
                                   1,     // Encoding method version
                                   null,  // Public key
                                   "https://open.charging.cloud/pools/1/stations/1/evse/1/publicKey"
                                   ),

                               // Total Fixed Costs
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Energy Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Time Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Parking Time
                               TimeSpan.FromMinutes(120),

                               // Total Parking Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Reservation Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               "Remark!",
                               InvoiceReference_Id.Parse("Invoice:0815"),
                               true, // IsCredit
                               CreditReference_Id.Parse("Credit:0815"),

                               DateTime.Parse("2020-09-12")

                               );

            #endregion

            var JSON = CDR1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("CDR0001", JSON["id"].Value <String>());


            Assert.IsTrue(CDR.TryParse(JSON, out CDR CDR2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CDR1.CountryCode, CDR2.CountryCode);
            Assert.AreEqual(CDR1.PartyId, CDR2.PartyId);
            Assert.AreEqual(CDR1.Id, CDR2.Id);

            Assert.AreEqual(CDR1.Start.ToIso8601(), CDR2.Start.ToIso8601());
            Assert.AreEqual(CDR1.End.ToIso8601(), CDR2.End.ToIso8601());
            Assert.AreEqual(CDR1.CDRToken, CDR2.CDRToken);
            Assert.AreEqual(CDR1.AuthMethod, CDR2.AuthMethod);
            Assert.AreEqual(CDR1.Location, CDR2.Location);
            Assert.AreEqual(CDR1.Currency, CDR2.Currency);
            Assert.AreEqual(CDR1.ChargingPeriods, CDR2.ChargingPeriods);
            Assert.AreEqual(CDR1.TotalCosts, CDR2.TotalCosts);
            Assert.AreEqual(CDR1.TotalEnergy, CDR2.TotalEnergy);
            Assert.AreEqual(CDR1.TotalTime, CDR2.TotalTime);

            Assert.AreEqual(CDR1.SessionId, CDR2.SessionId);
            Assert.AreEqual(CDR1.AuthorizationReference, CDR2.AuthorizationReference);
            Assert.AreEqual(CDR1.MeterId, CDR2.MeterId);
            Assert.AreEqual(CDR1.EnergyMeter, CDR2.EnergyMeter);
            Assert.AreEqual(CDR1.TransparencySoftwares, CDR2.TransparencySoftwares);
            Assert.AreEqual(CDR1.Tariffs, CDR2.Tariffs);
            Assert.AreEqual(CDR1.SignedData, CDR2.SignedData);
            Assert.AreEqual(CDR1.TotalFixedCosts, CDR2.TotalFixedCosts);
            Assert.AreEqual(CDR1.TotalEnergyCost, CDR2.TotalEnergyCost);
            Assert.AreEqual(CDR1.TotalTimeCost, CDR2.TotalTimeCost);
            Assert.AreEqual(CDR1.TotalParkingTime, CDR2.TotalParkingTime);
            Assert.AreEqual(CDR1.TotalParkingCost, CDR2.TotalParkingCost);
            Assert.AreEqual(CDR1.TotalReservationCost, CDR2.TotalReservationCost);
            Assert.AreEqual(CDR1.Remark, CDR2.Remark);
            Assert.AreEqual(CDR1.InvoiceReferenceId, CDR2.InvoiceReferenceId);
            Assert.AreEqual(CDR1.Credit, CDR2.Credit);
            Assert.AreEqual(CDR1.CreditReferenceId, CDR2.CreditReferenceId);

            Assert.AreEqual(CDR1.LastUpdated.ToIso8601(), CDR2.LastUpdated.ToIso8601());
        }
Example #15
0
        public static void CDR_DeserializeGitHub_Test01()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"": ""BE"",
                           ""party_id"": ""BEC"",
                           ""id"": ""12345"",
                           ""start_date_time"": ""2015-06-29T21:39:09Z"",
                           ""end_date_time"": ""2015-06-29T23:37:32Z"",
                           ""cdr_token"": {
                             ""uid"": ""012345678"",
                             ""type"": ""RFID"",
                             ""contract_id"": ""DE8ACC12E46L89""
                           },
                           ""auth_method"": ""WHITELIST"",
                           ""cdr_location"": {
                             ""id"": ""LOC1"",
                             ""name"": ""Gent Zuid"",
                             ""address"": ""F.Rooseveltlaan 3A"",
                             ""city"": ""Gent"",
                             ""postal_code"": ""9000"",
                             ""country"": ""BEL"",
                             ""coordinates"": {
                               ""latitude"": ""3.729944"",
                               ""longitude"": ""51.047599""
                             },
                             ""evse_uid"": ""3256"",
                             ""evse_id"": ""BE*BEC*E041503003"",
                             ""connector_id"": ""1"",
                             ""connector_standard"": ""IEC_62196_T2"",
                             ""connector_format"": ""SOCKET"",
                             ""connector_power_type"": ""AC_1_PHASE""
                           },
                           ""currency"": ""EUR"",
                           ""tariffs"": [{
                             ""country_code"": ""BE"",
                             ""party_id"": ""BEC"",
                             ""id"": ""12"",
                             ""currency"": ""EUR"",
                             ""elements"": [{
                               ""price_components"": [{
                                 ""type"": ""TIME"",
                                 ""price"": 2.00,
                                 ""vat"": 10.0,
                                 ""step_size"": 300
                               }]
                             }],
                             ""last_updated"": ""2015-02-02T14:15:01Z""
                           }],
                           ""charging_periods"": [{
                             ""start_date_time"": ""2015-06-29T21:39:09Z"",
                             ""dimensions"": [{
                               ""type"": ""TIME"",
                               ""volume"": 1.973
                             }],
                             ""tariff_id"": ""12""
                           }],
                           ""total_cost"": {
                             ""excl_vat"": 4.00,
                             ""incl_vat"": 4.40
                           },
                           ""total_energy"": 15.342,
                           ""total_time"": 1.973,
                           ""total_time_cost"": {
                             ""excl_vat"": 4.00,
                             ""incl_vat"": 4.40
                           },
                           ""last_updated"": ""2015-06-29T22:01:13Z""
                         }";

            #endregion

            Assert.IsTrue(CDR.TryParse(JSON, out CDR parsedCDR, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CountryCode.Parse("BE"), parsedCDR.CountryCode);
            Assert.AreEqual(Party_Id.Parse("BEC"), parsedCDR.PartyId);
            Assert.AreEqual(CDR_Id.Parse("12345"), parsedCDR.Id);
            //Assert.AreEqual(true,                                                  parsedCDR.Publish);
            //Assert.AreEqual(CDR1.Start.    ToIso8601(),                            parsedCDR.Start.    ToIso8601());
            //Assert.AreEqual(CDR1.End.Value.ToIso8601(),                            parsedCDR.End.Value.ToIso8601());
            //Assert.AreEqual(CDR1.kWh,                                              parsedCDR.kWh);
            //Assert.AreEqual(CDR1.CDRToken,                                         parsedCDR.CDRToken);
            //Assert.AreEqual(CDR1.AuthMethod,                                       parsedCDR.AuthMethod);
            //Assert.AreEqual(CDR1.AuthorizationReference,                           parsedCDR.AuthorizationReference);
            //Assert.AreEqual(CDR1.CDRId,                                            parsedCDR.CDRId);
            //Assert.AreEqual(CDR1.EVSEUId,                                          parsedCDR.EVSEUId);
            //Assert.AreEqual(CDR1.ConnectorId,                                      parsedCDR.ConnectorId);
            //Assert.AreEqual(CDR1.MeterId,                                          parsedCDR.MeterId);
            //Assert.AreEqual(CDR1.EnergyMeter,                                      parsedCDR.EnergyMeter);
            //Assert.AreEqual(CDR1.TransparencySoftwares,                            parsedCDR.TransparencySoftwares);
            //Assert.AreEqual(CDR1.Currency,                                         parsedCDR.Currency);
            //Assert.AreEqual(CDR1.ChargingPeriods,                                  parsedCDR.ChargingPeriods);
            //Assert.AreEqual(CDR1.TotalCosts,                                       parsedCDR.TotalCosts);
            //Assert.AreEqual(CDR1.Status,                                           parsedCDR.Status);
            //Assert.AreEqual(CDR1.LastUpdated.ToIso8601(),                          parsedCDR.LastUpdated.ToIso8601());
        }