Exemplo n.º 1
0
        public static void Tariff0002()
        {
            var tariff = new Tariff(Tariff_Id.Parse("12"),
                                    Currency.EUR,
                                    TariffText: I18NString.Create(Languages.eng, "2 euro p/hour").
                                    Add(Languages.nld, "2 euro p/uur"),
                                    TariffElements: Enumeration.Create(
                                        new TariffElement(
                                            new PriceComponent(DimensionType.TIME, 2.00M, 300)
                                            )
                                        )
                                    );

            var expected = new JObject(new JProperty("id", "12"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_text", new JArray(
                                                         new JObject(new JProperty("language", "en"), new JProperty("text", "2 euro p/hour")),
                                                         new JObject(new JProperty("language", "nl"), new JProperty("text", "2 euro p/uur"))
                                                         )),
                                       new JProperty("elements", new JArray(
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   )))
                                                             )
                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }
Exemplo n.º 2
0
        public static void Tariff0001()
        {
            var tariff = new Tariff(Tariff_Id.Parse("12"),
                                    Currency.EUR,
                                    TariffElements: Enumeration.Create(
                                        new TariffElement(
                                            new PriceComponent(DimensionType.TIME, 2.00M, 300)
                                            )
                                        )
                                    );

            var expected = new JObject(new JProperty("id", "12"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("elements", new JArray(
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   )))
                                                             )
                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }
Exemplo n.º 3
0
        public static void Tariff0003()
        {
            var tariff = new Tariff(Tariff_Id.Parse("12"),
                                    Currency.EUR,
                                    TariffUrl:      new Uri("https://company.com/tariffs/12"),
                                    TariffElements: Enumeration.Create(
                                        new TariffElement(
                                            PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(300))
                                            )
                                        )
                                    );

            var expected = new JObject(new JProperty("id", "12"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_url", "https://company.com/tariffs/12"),
                                       new JProperty("elements", new JArray(
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   )))
                                                             )
                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }
Exemplo n.º 4
0
    public EnumerationBuilder AddEnumeration(string name)
    {
        var enumeration = Enumeration.Create(this, name);

        Build.Enumerations.Add(enumeration.Instance);
        return(enumeration);
    }
Exemplo n.º 5
0
        public static void Tariff0004()
        {
            var tariff = new Tariff(Tariff_Id.Parse("11"),
                                    Currency.EUR,
                                    TariffUrl:      new Uri("https://company.com/tariffs/11"),
                                    TariffElements: new List <TariffElement>()
            {
                // 2.50 euro start tariff
                new TariffElement(
                    PriceComponent.FlatRate(2.50M)
                    ),

                // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.00M, TimeSpan.FromSeconds(900)),
                    TariffRestriction.MaxPower(32M)
                    ),

                // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.25M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Saturday,
                                              DayOfWeek.Sunday
                                              ))
                    ),


                // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(5M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(9).To(18),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(6M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(10).To(17),
                                          DayOfWeek:  new DayOfWeek[] {
                    DayOfWeek.Saturday
                })
                    )
            }
                                    );

            var expected = new JObject(new JProperty("id", "11"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_url", "https://company.com/tariffs/11"),
                                       new JProperty("elements", new JArray(

                                                         // 2.50 euro start tariff
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "FLAT"),
                                                                                   new JProperty("price", "2.50"),
                                                                                   new JProperty("step_size", 1)
                                                                                   )))
                                                             ),


                                                         // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.00"),
                                                                                   new JProperty("step_size", 900)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("max_power", "32.00")
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.25"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY", "SUNDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "5.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "09:00"),
                                                                                   new JProperty("end_time", "18:00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "6.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "10:00"),
                                                                                   new JProperty("end_time", "17:00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY"))
                                                                                   )
                                                                               ))
                                                             )

                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }