public void TwoCNOTs()
        {
            QCTraceSimulator sim = GetTraceSimForMetrics();

            GetTest <TwoCNOTsTest>(sim)();

            void AssertEqualMetric(double value, string metric)
            {
                Assert.Equal(value, sim.GetMetric <TwoCNOTsTest>(metric));
            }

            AssertEqualMetric(2, DepthCounter.Metrics.Depth);
            AssertEqualMetric(2, PrimitiveOperationsGroupsNames.CNOT);
            AssertEqualMetric(3, WidthCounter.Metrics.ExtraWidth);
            AssertEqualMetric(0, DepthCounter.Metrics.StartTimeDifference);
        }
Exemple #2
0
        public PassTestViewModel(MainViewModel main, Action close, Dispatcher dispatcher)
        {
            MainViewModel = main;
            _close        = close;

            if (main.SelectedItemQuestion != null)
            {
                SelectedQuestion = main.SelectedItemQuestion;
            }

            _getTest = new GetTest();

            //  DispatcherTimer setup
            _dispatcherTimer       = new DispatcherTimer();
            TimeLeft               = MainViewModel.SelectedItemTest.Time;
            _dispatcherTimer.Tick += (sender, args) =>
            {
                TimeLeft--;
                if (TimeLeft <= 0)
                {
                    var result = _getTest.ResulOfTest(_choosedAnsewers.Values.ToList(), QuestionsList.Count);
                    MessageBox.Show("Time is over\n" + result);
                    close();
                    _dispatcherTimer.Stop();
                }
            };
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            _dispatcherTimer.Start();
        }
Exemple #3
0
        public async Task <bool> TestMessage(string message)
        {
            const string route = "/api/dev/json";

            if (_token == null || !_token.IsValid)
            {
                return(false);
            }

            SendTest testS    = new SendTest(message);
            string   json     = JsonConvert.SerializeObject(testS);
            string   response = await Post(json, route);

            GetTest testG = null;

            try
            {
                testG = JsonConvert.DeserializeObject <GetTest>(response);
            }
            catch (Exception)
            {
                return(false);
            }

            return(testG.Success);
        }
Exemple #4
0
 public MainViewModel()
 {
     _getTest                 = new GetTest();
     _basicsOperationTest     = new BasicsOperationTest();
     _basicsOperationQuestion = new BasicsOperationQuestion();
     _basicsOperationAnswer   = new BasicsOperationAnswer();
     RefreshTest();
 }
        public void ThreeCNOTs()
        {
            QCTraceSimulator sim = GetTraceSimForMetrics();

            GetTest <ThreeCNOTsTest>(sim)();

            void AssertEqualMetric(double value, string metric)
            {
                Assert.Equal(value, sim.GetMetric <ThreeCNOTsTest>(metric));
            }

            AssertEqualMetric(3, DepthCounter.Metrics.Depth);
            AssertEqualMetric(3, PrimitiveOperationsGroupsNames.CNOT);
            AssertEqualMetric(3, WidthCounter.Metrics.ExtraWidth);
            AssertEqualMetric(0, DepthCounter.Metrics.StartTimeDifference);

            Dictionary <string, string> csvRes = sim.ToCSV();

            foreach (KeyValuePair <string, string> kv in csvRes)
            {
                output.WriteLine($"Result of running {kv.Key} are:");
                output.WriteLine(kv.Value);
            }
        }
        public async Task <GetTestResponse> GetTest(Guid testId)
        {
            var query = new GetTest(testId);

            return(await _queryProcessor.ProcessQuery <GetTest, GetTestResponse>(query));
        }
        public void AllocatedConstraint()
        {
            var sim = GetTraceSimForMetrics();

            GetTest <AllocatedConstraintTest>(sim)();
        }
        public void ForcedMeasuremenet()
        {
            var sim = GetTraceSimForMetrics();

            GetTest <ForcedMeasurementTest>(sim)();
        }
        public void SwappedMeasurement()
        {
            var sim = GetTraceSimForMetrics();

            GetTest <SwappedMeasurementTest>(sim)();
        }
        public void MeausermentPreverseConstraint()
        {
            var sim = GetTraceSimForMetrics();

            GetTest <MeausermentPreverseConstraintTest>(sim)();
        }