public async Task ensureGetAllAlgorithmsSucceeds()
        {
            var response = await client.GetAsync(urlBase);

            var responseString = await response.Content.ReadAsStringAsync();

            GetAllAlgorithmsModelView list = JsonConvert.DeserializeObject <GetAllAlgorithmsModelView>(responseString);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(Enum.GetValues(typeof(RestrictionAlgorithm)).Length, list.Count);
        }
예제 #2
0
        /// <summary>
        /// Creates an instance of GetAllAlgorithmsModelView from an IEnumerable of Algorithm.
        /// </summary>
        /// <param name="algorithms">IEnumerable of Algorithm being converted.</param>
        /// <returns>Instance of GeAllAlgorithmsModelView with the IEnumerable's data.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when the provided IEnumerable of Algorithm.</exception>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the instances of Algorithm in the IEnumerable is null.</exception>
        public static GetAllAlgorithmsModelView fromCollection(IEnumerable <Algorithm> algorithms)
        {
            if (algorithms == null)
            {
                throw new ArgumentNullException(NULL_ALGORITHM_COLLECTION);
            }

            GetAllAlgorithmsModelView allAlgorithmsModelView = new GetAllAlgorithmsModelView();

            foreach (Algorithm algorithm in algorithms)
            {
                allAlgorithmsModelView.Add(fromEntityAsBasic(algorithm));
            }

            return(allAlgorithmsModelView);
        }
예제 #3
0
        /// <summary>
        /// Returns an instance of GetAllAlgorithmsModelView representing all the available types of Algorithm.
        /// </summary>
        /// <returns>GetAllAlgorithmsModelView representing all the available types of Algorithm.</returns>
        public GetAllAlgorithmsModelView getAllAlgorithms()
        {
            Array availableAlgorithms = Enum.GetValues(typeof(RestrictionAlgorithm));

            if (availableAlgorithms.Length == 0)
            {
                throw new ResourceNotFoundException(NO_ALGORITHMS_AVAILABLE);
            }

            GetAllAlgorithmsModelView allAlgorithmsModelView = new GetAllAlgorithmsModelView();

            foreach (RestrictionAlgorithm restrictionAlgorithm in availableAlgorithms)
            {
                Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);
                GetBasicAlgorithmModelView algorithmModelView = AlgorithmModelViewService.fromEntityAsBasic(algorithm);
                allAlgorithmsModelView.Add(algorithmModelView);
            }

            return(allAlgorithmsModelView);
        }