示例#1
0
        public void GetOptionStatusHandlesLargeAmmountsOfData()
        {
            for (int index = 0; index < 1000 * 1000; index++)
            {
                DateTime endTime   = GetEndTime();
                DateTime beginTime = GetBeginTime(endTime);
                string   name      = GetName();
                bool     success   = GetSuccess();

                OptionResult.Create(_mongoConnection, beginTime, endTime, name, success, 0);
            }

            DateTime start = DateTime.Now;

            OptionResult.GetOptionStatus(_mongoConnection);

            DateTime s**t = DateTime.Now;

            Assert.Less(s**t - start, TimeSpan.FromMinutes(1));
        }
示例#2
0
        public void GetOptionStatusGivesCorrectData()
        {
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddMinutes(-1), "name1", true, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddMinutes(-12), "name1", true, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddMinutes(-65), "name1", true, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddHours(-20), "name1", false, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddHours(-30), "name1", false, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddMinutes(-5), "name2", true, 0);
            OptionResult.Create(_mongoConnection, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1).AddMinutes(-5), "name2", false, 0);

            Clock.NowFunc = () => new DateTime(2000, 1, 1);

            Dictionary <string, OptionStatusLine> optionStatus = OptionResult.GetOptionStatus(_mongoConnection);

            Assert.AreEqual(5, optionStatus["name1"].ExecutionTotal);
            Assert.AreEqual(0, optionStatus["name1"].Fail10Minute);
            Assert.AreEqual(0, optionStatus["name1"].Fail1Hour);
            Assert.AreEqual(1, optionStatus["name1"].Fail24Hour);
            Assert.AreEqual(2, optionStatus["name1"].FailTotal);
            Assert.AreEqual(1, optionStatus["name1"].Success10Minute);
            Assert.AreEqual(2, optionStatus["name1"].Success1Hour);
            Assert.AreEqual(3, optionStatus["name1"].Success24Hour);
            Assert.AreEqual(3, optionStatus["name1"].SuccessTotal);
        }