Exemple #1
0
        public void Contains(ContainsScenario scenario)
        {
            IMyCollection <TestItem> list = (IMyCollection <TestItem>)scenario.List;

            bool contains = list.Contains(scenario.ToFind);

            Assert.AreEqual(scenario.Expected, contains);
        }
Exemple #2
0
        public void Remove(RemoveScenario scenario)
        {
            IMyCollection <TestItem> list = (IMyCollection <TestItem>)scenario.List;

            bool wasRemoved = list.Remove(scenario.ToRemove);

            Assert.AreEqual(scenario.ExpectedRemoved, wasRemoved);
            AssertHelper.AreCollectionSame(scenario.ExpectedElements, list);
        }
        public static IEnumerable <TOutput> AsEnumerableOf <T, TOutput>(this IMyCollection <T> collection)
        {
            var converter = TypeDescriptor.GetConverter(typeof(T));

            foreach (var item in collection)
            {
                TOutput result = (TOutput)converter.ConvertTo(item, typeof(TOutput));
                yield return(result);
            }
        }
Exemple #4
0
        public void Add(AddScenario scenario)
        {
            IMyCollection <TestItem> list = (IMyCollection <TestItem>)scenario.List;

            foreach (var item in scenario.ItemsToAdd)
            {
                list.Add(item);
            }

            AssertHelper.AreCollectionSame(scenario.ExpectedElements, list);
        }
Exemple #5
0
        public void ContainsPerformance(ContainsPerformanceScenario scenario)
        {
            IMyCollection <TestItem> list = (IMyCollection <TestItem>)scenario.List;

            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (var item in scenario.ToFind)
            {
                list.Contains(item);
            }
            stopwatch.Stop();

            this.SaveResultsToFile(
                list.GetType(),
                MethodBase.GetCurrentMethod().Name,
                list.Count,
                stopwatch.ElapsedMilliseconds);
        }
Exemple #6
0
        public void AddPerformance(AddScenario scenario)
        {
            IMyCollection <TestItem> list = (IMyCollection <TestItem>)scenario.List;

            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (var item in scenario.ItemsToAdd)
            {
                list.Add(item);
            }
            stopwatch.Stop();

            this.SaveResultsToFile(
                list.GetType(),
                MethodBase.GetCurrentMethod().Name,
                scenario.ItemsToAdd.Length,
                stopwatch.ElapsedMilliseconds);
        }
Exemple #7
0
        private static void WorkWithChoice(IMyCollection <double> collection, int choise)
        {
            switch (choise)
            {
            case 1:
                Console.WriteLine("Write element: ");
                if (double.TryParse(Console.ReadLine(), out double value))
                {
                    collection.WriteElement(value);
                }
                break;

            case 2:
                Console.WriteLine($"This element readed: {collection.ReadElement()}");
                break;

            case 3:
                Console.WriteLine($"The output element is: {collection.CheckElement()}");
                break;

            case 4:
                collection.DisplayAll();
                break;

            case 5:
                var asInt = collection.AsEnumerableOf <double, int>();
                foreach (var item in asInt)
                {
                    Console.WriteLine(item);
                }
                break;

            case 6:
                Environment.Exit(1);
                break;

            default:
                Console.WriteLine("You made wrong choise");
                break;
            }
        }
 public void AddRange(IMyCollection <T> items)
 {
 }
Exemple #9
0
 public Test()
 {
     IMyCollection <MyClass>   bag     = new MyCollection <MyClass>();
     IMyCollection <BaseClass> baseBag = bag; // funktioniert wegen out
 }