示例#1
0
        private void TimerOnTick(object sender, EventArgs eventArgs)
        {
            var r = new Random();

            AngularGaugeValue += r.NextDouble() > 0.5 ? r.NextDouble() * 10 : -r.NextDouble() * 10;
            Yes.Value         += r.NextDouble() > 0.5 ? r.NextDouble() * 1 : -r.NextDouble() * 1;
            No.Value          += r.NextDouble() > 0.5 ? r.NextDouble() * 1 : -r.NextDouble() * 1;
            Maybe.Value       += r.NextDouble() > 0.5 ? r.NextDouble() * 1 : -r.NextDouble() * 1;

            if (r.NextDouble() > .7)
            {
                foreach (var observableValue in Line1)
                {
                    observableValue.Value = r.NextDouble() * 10;
                }
            }

            Task.Run(() =>
            {
                Thread.Sleep(500);
                DynamicValues.Add(new ObservableValue(r.NextDouble() * 10));
                DynamicValues.RemoveAt(0);
                Thread.Sleep(500);
                DynamicValues.Add(new ObservableValue(r.NextDouble() * 10));
                DynamicValues.RemoveAt(0);
            });
        }
示例#2
0
        public void TrySetMember_Called_InvalidOperationException()
        {
            var sut = new DynamicValues(new Dictionary <string, object>());

            // Act
            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <InvalidOperationException>(() => sut.TrySetMember(null, null));
        }
示例#3
0
        public Boolean Contains(String PropertyName)
        {
            PropertyName = PropertyName.ToUpper();

            if (PropertyName == "THIS")
            {
                return(true);
            }

            if (StaticValues != null && StaticValues.ContainsKey(PropertyName))
            {
                return(true);
            }

            return(DynamicValues.ContainsKey(PropertyName));
        }
示例#4
0
        public object this[String PropertyName]
        {
            get
            {
                Object val = null;
                PropertyName = PropertyName.ToUpper();

                if (PropertyName == "THIS")
                {
                    return(ParentObject ?? this);
                }

                if (StaticValues != null)
                {
                    if (StaticValues.TryGetValue(PropertyName, out val))
                    {
                        return(val);
                    }
                }

                DynamicValues.TryGetValue(PropertyName, out val);
                return(val);
            }
            set
            {
                PropertyName = PropertyName.ToUpper();

                if (PropertyName != "THIS")
                {
                    if (StaticValues != null && StaticValues.ContainsKey(PropertyName))
                    {
                        StaticValues = StaticValues;
                    }
                    else
                    {
                        DynamicValues[PropertyName] = value;
                    }
                }

                if (ValueChanged != null)
                {
                    ValueChanged.Invoke(this, new EventArgs());
                }
            }
        }
示例#5
0
        public Boolean Contains(String PropertyName)
        {
#if CASE_INSENSITIVE
            PropertyName = PropertyName.ToUpper();

            if (PropertyName == "THIS")
            {
                return(true);
            }
#else
            if (PropertyName == "this")
            {
                return(true);
            }
#endif

            return(DynamicValues.ContainsKey(PropertyName));
        }
示例#6
0
        public object this[String PropertyName]
        {
            get
            {
                Object val = null;

#if CASE_INSENSITIVE
                PropertyName = PropertyName.ToUpper();

                if (DynamicValues.TryGetValue(PropertyName, out val))
                {
                    return(val);
                }

                if (PropertyName == "THIS")
                {
                    return(ParentObject ?? this);
                }
#else
                if (DynamicValues.TryGetValue(PropertyName, out val))
                {
                    return(val);
                }

                if (PropertyName == "this")
                {
                    return(ParentObject ?? this);
                }
#endif

                return(null);
            }
            set
            {
                //PropertyName = PropertyName.ToUpper();

                DynamicValues[PropertyName] = value;

                if (ValueChanged != null)
                {
                    ValueChanged.Invoke(this, new System.EventArgs());
                }
            }
        }
示例#7
0
 public void Constructor_CalledWithNullStringObject_NoExceptionThrown()
 {
     // Act
     var sut = new DynamicValues(default(IEnumerable <KeyValuePair <string, object> >));
 }
示例#8
0
        public int Execute(Context context)
        {
            if (!Validate())
            {
                ValidationMessages += "The test suite does not validate.";
                //throw new ApplicationException("The test suite is not in a valid format. It cannot be executed until the errors have been corrected.");
            }

            if (ParentTestSuite == null)
            {
                Statistics.Reset();
            }

#if !SQL2005
            DynamicValues.Apply();
#endif

            OnRaiseTestSuiteStarted(new TestSuiteStartedEventArgs());

            try
            {
                ExecuteCommandSet(TestSuiteSetup);
            }
            catch (Exception)
            {
                OnRaiseTestSuiteFailed(new TestSuiteFailedEventArgs(DateTime.Now, "The test suite setup failed."));

                throw;
            }

            foreach (Test test in Tests.Values)
            {
                try
                {
                    test.TestStarted   += TestStarted;
                    test.TestCompleted += TestCompleted;

                    test.Execute(context);
                }
                catch (Exception ex)
                {
                    OnRaiseTestCompleted(new TestCompletedEventArgs(DateTime.Now, test.PackageLocation, test.Task, test.Name, ex.Message, false));
                }
                finally
                {
                    test.TestCompleted -= TestCompleted;
                    test.TestStarted   -= TestStarted;
                }
            }

            foreach (TestRef testRef in TestRefs.Values)
            {
                // TODO: Add context
                testRef.Execute();
            }

            try
            {
                ExecuteCommandSet(TestSuiteTeardown);
            }
            catch (Exception)
            {
                OnRaiseTestSuiteFailed(new TestSuiteFailedEventArgs(DateTime.Now, "The test suite teardown failed."));

                throw;
            }

            int totalTests  = Statistics.GetStatistic(StatisticEnum.TestCount);
            int failedTests = Statistics.GetStatistic(StatisticEnum.TestFailedCount);
            int passedTests = Statistics.GetStatistic(StatisticEnum.TestPassedCount);

            string completionMessage;

            if (failedTests < 1)
            {
                completionMessage = "The test suite has completed successfully, " + (totalTests == 1 ? "1 unit test has passed." : string.Format("{0} unit tests have passed.", totalTests.ToString("N0")));
            }
            else
            {
                completionMessage = string.Format("The test suite has completed with {0} unit test failure{1} and {2} unit test success{3}.", failedTests.ToString("N0"), failedTests == 1 ? string.Empty : "s", passedTests.ToString("N0"), passedTests == 1 ? string.Empty : "es");
            }

            OnRaiseTestSuiteCompleted(new TestSuiteCompletedEventArgs(DateTime.Now, totalTests, failedTests, passedTests, completionMessage, failedTests < 1));

            return(Statistics.GetStatistic(StatisticEnum.TestCount));
        }