Ejemplo n.º 1
0
 public static void MyClassInitialize(TestContext testContext)
 {
     DictionaryTest.MyClassCleanup();             //in case the LM is still open
     DictionaryTest.ExtractTestDictionary();
     user = UserFactory.Create((GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); },
                               new ConnectionStringStruct(DatabaseType.Xml, DictionaryTest.testDic, false), (DataAccessErrorDelegate) delegate { return; }, testContext);
     Assert.IsTrue(File.Exists(DictionaryTest.testDic), "Test Learning Module file cannot be found.");
 }
Ejemplo n.º 2
0
    public void CloneDictionary()
    {
        var input = new DictionaryTest();

        var output = _serializer.Clone(log, input);

        //Assert.AreEqual(input, output);
    }
Ejemplo n.º 3
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                // C#
                WhileLoopTests.Execute();
                ForeachLoopTests.Execute();

                // System
                ObjectTests.Execute();
                ArrayTests.Execute();
                StringTest.Execute();
                ByteTest.Execute();
                SByteTest.Execute();
                Int16Test.Execute();
                UInt16Test.Execute();
                Int32Test.Execute();
                UInt32Test.Execute();
                Int64Test.Execute();
                UInt64Test.Execute();
                CharTest.Execute();
                BooleanTest.Execute();
                SingleTest.Execute();
                DoubleTest.Execute();
                MathTest.Execute();
                ConvertTests.Execute();

                //mDebugger.Send("Thread test start of 500 ms");
                //ThreadTest.Execute();
                //mDebugger.Send("Thread test end");

                //DecimalTest.Execute();
                BitConverterTest.Execute();
                UnsafeCodeTest.Execute();
                DelegatesTest.Execute();
                RandomTests.Execute();

                // System.Collections.Generic
                ListTest.Execute();
                QueueTest.Execute();
                DictionaryTest.Execute();

                // System.Text
                EncodingTest.Execute();

                TestController.Completed();
            }
            catch (Exception e)
            {
                mDebugger.Send("Exception occurred: " + e.Message);
                mDebugger.Send(e.Message);
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                TestController.Failed();
            }
        }
Ejemplo n.º 4
0
    public void SerializeDictionaryCircularReferences()
    {
        var input = new DictionaryTest();

        _serializer.Save(Call, input);
        var output = _serializer.Load <DictionaryTest>(Call);

        Assert.NotNull(output);

        //Assert.AreEqual(input, output);
    }
Ejemplo n.º 5
0
        public void SerializesDictionary()
        {
            var serializer = MyProject.GetSerializer <DictionaryTest>();

            var dictTest = new DictionaryTest();

            dictTest.Dict.Add("foo", 1);
            dictTest.Dict.Add("bar", 2);

            var content = serializer.Serialize(dictTest);

            //File.WriteAllText(@"Data\serializes_dict.txt", content);

            Assert.Equal(File.ReadAllText(@"Data\serializes_dict.txt"), content);
        }
Ejemplo n.º 6
0
        public void CardStackUnitTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                using (Dictionary dictionary = TestInfrastructure.GetConnection(TestContext))
                {
                    DictionaryTest.FillDictionary(dictionary);

                    CardStack target = new CardStack(new LearnLogic(MLifterTest.DAL.OpenUserProfileTests.GetUserAdmin, (MLifter.DAL.DataAccessErrorDelegate) delegate { return; }));
                    target.StackChanged += new EventHandler(CardStack_StackChanged);
                    cardstackChanged     = false;
                    target.Clear();
                    Assert.IsTrue(cardstackChanged, "CardStackChanged event did not fire for Clear.");

                    int      cardcount  = 0;
                    int      rightcount = 0;
                    TimeSpan duration   = new TimeSpan(0);

                    foreach (ICard card in dictionary.Cards.Cards)
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            cardcount++;
                            bool promoted = GetRandBool();
                            if (promoted)
                            {
                                rightcount++;
                            }
                            DateTime asked    = DateTime.Now - new TimeSpan(0, 0, random.Next(1000));
                            DateTime answered = DateTime.Now;
                            duration += (answered - asked);
                            AnswerResult result    = promoted ? AnswerResult.Correct : AnswerResult.Wrong;
                            StackCard    stackCard = new StackCard(card, result, promoted, EQueryDirection.Question2Answer, LearnModes.Word, asked, answered, Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentCulture, card.Answer.ToString(), 0, 0, false, dictionary, 0);

                            cardstackChanged = false;
                            target.Push(stackCard);
                            Assert.IsTrue(cardstackChanged, "CardStackChanged event did not fire for Push.");
                        }
                    }

                    Assert.AreEqual(cardcount, target.Count, "Not all cards were added to the stack.");
                    Assert.AreEqual(duration, target.SessionDuration, "Session duration sum does not match.");
                    Assert.AreEqual(rightcount, target.RightCount, "RightCount does not match.");
                    Assert.AreEqual(cardcount - rightcount, target.WrongCount, "WrongCount does not match.");
                    Assert.IsTrue(rightcount > 0 && target.VisibleStack.Count > 0, "No StackCards in VisibleStack property.");
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                //// C#
                ObjectTest.Execute();
                WhileLoopTests.Execute();
                ForeachLoopTests.Execute();

                //mDebugger.Send("Thread test start of 500 ms");
                //ThreadTest.Execute();
                //mDebugger.Send("Thread test end");

                SpanTest.Execute();
                //DecimalTest.Execute();
                BitConverterTest.Execute();
                UnsafeCodeTest.Execute();
                DelegatesTest.Execute();
                EventsTest.Execute();
                RandomTests.Execute();
                ConvertTests.Execute();

                // System.Collections
                HashtableTest.Execute();

                // System.Collections.Generic
                ListTest.Execute();
                QueueTest.Execute();
                DictionaryTest.Execute();

                // System.Text
                StringBuilderTest.Execute();
                EncodingTest.Execute();

                TestController.Completed();
            }
            catch (Exception e)
            {
                mDebugger.Send("Exception occurred: " + e.Message);
                mDebugger.Send(e.Message);
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                TestController.Failed();
            }
        }
Ejemplo n.º 8
0
 public static void Main(string[] args)
 {
     Console.WriteLine("-------------------------------------------List----------------------------------------------");
     ListTest.Main();
     Console.WriteLine("-------------------------------------------Dictionary----------------------------------------------");
     DictionaryTest.Main();
     Console.WriteLine("-------------------------------------------Delegates----------------------------------------------");
     DEL.DelegateTest.Delegates();
     Console.WriteLine("----------------------------------------------TypeTesting------------------------------------------");
     TypeTesting();
     CUST.ClassA.Print();
     CallCustomer();
     Console.WriteLine("----------------------------------------------Inhertience------------------------------------------");
     Inhertience();
     Console.WriteLine("----------------------------------------------Properties------------------------------------------");
     PropertiesTest();
 }
Ejemplo n.º 9
0
        public void IntKeyTester()
        {
            var r = new DictionaryTest();

            r.Dictionary = new IntDictionary();
            r.Dictionary.Add(1, "blah 1");
            r.Dictionary.Add(2, "blah 2");
            r.Dictionary.Add(3, null);


            var cloner = new ObjectCloner();

            Assert.IsNotNull(cloner);

            var n = cloner.Clone(r);

            Assert.IsNotNull(n);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Dictionary <string, int> d1 = new Dictionary <string, int>();

            d1.Add("123", 1);
            d1.Add("431", 2);

            var getVauleByKey123 = d1["123"];//return 1

            DictionaryTest <string, int> dic = new DictionaryTest <string, int>();

            dic.Add("123", 1);
            dic.Add("431", 2);

            var dictionaryTest_getVauleByKey123 = dic["123"];


            Console.Write("Break.");
        }
Ejemplo n.º 11
0
        public void Can_convert_anonymous_object_to_ObjectDictionary()
        {
            var newObj = new { A = "a", B = 1, C = true, D = 2.0 };
            var type   = new DictionaryTest {
                A = "a", B = 1, C = true, D = 2.0
            };
            var expected = new Dictionary <string, object> {
                ["A"] = "a",
                ["B"] = 1,
                ["C"] = true,
                ["D"] = 2.0
            };

            var to = newObj.ToObjectDictionary();

            Assert.That(to, Is.EquivalentTo(expected));
            to = type.ToObjectDictionary();
            Assert.That(to, Is.EquivalentTo(expected));
            to = expected.ToObjectDictionary();
            Assert.That(to, Is.EquivalentTo(expected));
        }
Ejemplo n.º 12
0
 private static bool GetRandBool()
 {
     return(DictionaryTest.GetRandBool());
 }