Пример #1
0
 public void UpdateMealSetting(EPeriod item, bool value)
 {
     if (Items.ContainsKey(item))
     {
         Items[item] = value;
     }
     else
     {
         Items.Add(item, value);
     }
 }
        public async Task <SearchTerms> GetSearchTerms(string searchTerm, EPeriod period, int numberOfPeriods, bool relatedSearchTerms = false)
        {
            var queryParameters = new Dictionary <string, string>()
            {
                { "search-term", searchTerm },
                { "period", period.ToString() },
                { "number-of-periods", numberOfPeriods.ToString() },
                { "related-search-terms", relatedSearchTerms.ToString() }
            };
            var response = await Get("/insights/search-terms", queryParameters).ConfigureAwait(false);

            return(await BolApiHelper.GetContentFromResponse <SearchTerms>(response).ConfigureAwait(false));
        }
Пример #3
0
        private void SetConsumable(string consumable)
        {
            const short lenghtArrayConsumable = 2;
            var         consumableSplited     = consumable.Split(" ");

            if (consumableSplited.Length != lenghtArrayConsumable)
            {
                Quantity = 0;
                Period   = EPeriod.Unknown;
                return;
            }

            Quantity = Convert.ToInt32(consumableSplited[0]);
            var period = consumableSplited[1].ToLower();

            Period = Enum.GetValues(typeof(EPeriod)).Cast <EPeriod>()
                     .FirstOrDefault(x => period.Contains(x.ToString().ToLower()));
        }
Пример #4
0
        private void ConsumableBuilder(string consumableAPI)
        {
            Period   = EPeriod.Unknown;
            Quantity = errorNumber;

            var consumableAPISplited = consumableAPI.Split(" ");

            if (consumableAPISplited.Length == 2)
            {
                if (int.TryParse(consumableAPISplited[0], out int quantity))
                {
                    Quantity = quantity;
                }

                var consumable = consumableAPISplited[1].ToLower();

                var periodSearch = System.Enum.GetValues(typeof(EPeriod)).Cast <EPeriod>().ToList()
                                   .Where(x => consumable.ToLower().Contains(x.ToString().ToLower()));

                Period = (periodSearch.Count() > 0) ? periodSearch.First() : EPeriod.Unknown;
            }
        }
Пример #5
0
        public void Must_CalculateNumbersSupply(long distanceMGLT, int starshipMGLT, int consumableQuantity, EPeriod consumablePeriod, long expectedResult)
        {
            var consumable = new Consumable(consumableQuantity, consumablePeriod);
            var starship   = new Starship(string.Empty, starshipMGLT, consumable);

            var result = starship.CalculateSupply(distanceMGLT);

            Assert.Equal(result, expectedResult);
        }
Пример #6
0
        public void Must_InitializeProperly(string starShipName, int starshipMGLT, int consumableQuantity, EPeriod consumablePeriod)
        {
            var consumable = new Consumable(consumableQuantity, consumablePeriod);
            var starship   = new Starship(starShipName, starshipMGLT, consumable);

            Assert.Equal(starship.Name, starShipName);
            Assert.Equal(starship.MGLT, starshipMGLT);
            Assert.Equal(starship.Consumable.Quantity, consumableQuantity);
            Assert.Equal(starship.Consumable.Period, consumablePeriod);
        }
Пример #7
0
 public Consumable(int quantity, EPeriod period)
 {
     Quantity = quantity;
     Period   = period;
 }
Пример #8
0
        public void Must_InstantiateCorrectConstructorByAPI(string consumablePeriod, int expectedQuantity, EPeriod expectedPeriod)
        {
            var consumable = new Consumable(consumablePeriod);

            Assert.Equal(expectedQuantity, consumable.Quantity);
            Assert.Equal(expectedPeriod, consumable.Period);
        }
Пример #9
0
        public void Should_Be_Convert_ComsumableApi_To_Enumerator_And_Quantity(string consumableApi, int expectedQuantity, EPeriod expectedPeriod)
        {
            var consumable = new Consumable(consumableApi);

            Assert.Equal(expectedQuantity, consumable.Quantity);
            Assert.Equal(expectedPeriod, consumable.Period);
        }