/// <summary>
        /// IQ# Magic that checks that the reference implementation of a Kata's test runs successfully.
        /// </summary>
        public CheckKataMagic(IOperationResolver resolver, ICompilerService compiler, ILogger <KataMagic> logger)
        {
            this.Name          = $"%check_kata";
            this.Documentation = new Microsoft.Jupyter.Core.Documentation
            {
                Summary     = "Checks the reference implementation for a single kata's test.",
                Description =
                    "Substitutes the reference implementation for a " +
                    "single task into the cell, and reports whether the test " +
                    "passed successfully using the reference implementation.",
                Examples = new []
                {
                    "To check a test called `Test`:\n" +
                    "```\n" +
                    "In []: %check_kata T101_StateFlip \n",
                    "  ...: operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n",
                    "           // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
                    "           // Type X(q);\n",
                    "           // Then run the cell using Ctrl/⌘+Enter.\n",
                    "\n",
                    "           // ...\n",
                    "       }\n" +
                    "Out[]: Success!" +
                    "```\n"
                }
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Compiler = compiler;
            this.Logger   = logger;
        }
Exemple #2
0
 public DCPUVM()
 {
     sp = 0xffff;
     PC = 0x0000;
     operandResolver   = new OperandResolver(this);
     operationResolver = new OperationResolver();
 }
Exemple #3
0
        /// <summary>
        /// IQ# Magic that enables executing the Katas on Jupyter.
        /// </summary>
        public KataMagic(IOperationResolver resolver, ISnippets snippets, ILogger <KataMagic> logger, IConfigurationSource configurationSource)
        {
            this.Name          = $"%kata";
            this.Documentation = new Microsoft.Jupyter.Core.Documentation
            {
                Summary     = "Executes a single test.",
                Description = "Executes a single test, and reports whether the test passed successfully.",
                Examples    = new []
                {
                    "To run a test called `Test`:\n" +
                    "```\n" +
                    "In []: %kata T101_StateFlip \n" +
                    "       operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n" +
                    "           // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n" +
                    "           // Type X(q);\n" +
                    "           // Then run the cell using Ctrl/⌘+Enter.\n" +
                    "\n" +
                    "           // ...\n" +
                    "       }\n" +
                    "Out[]: Qubit in invalid state. Expecting: Zero\n" +
                    "       \tExpected:\t0\n" +
                    "       \tActual:\t0.5000000000000002\n" +
                    "       Try again!\n" +
                    "```\n"
                }
            };
            this.Kind                = SymbolKind.Magic;
            this.Execute             = this.Run;
            this.ConfigurationSource = configurationSource;

            this.Resolver   = resolver;
            this.Snippets   = snippets;
            this.Logger     = logger;
            this.AllAnswers = new Dictionary <OperationInfo, OperationInfo>();
        }
        public void Fluently_assigning_operation_resolver_returns_configuration(IOperationResolver resolver)
        {
            var sut = new FakeWorkflowConfiguration();

            var result = sut.WithResolver(resolver);

            Assert.Equal(sut, result);
        }
        public void You_can_fluently_assign_the_operation_resolver(IOperationResolver resolver)
        {
            var sut = new FakeWorkflowConfiguration();

            sut.WithResolver(resolver);

            Assert.Equal(resolver, sut.Resolver);
        }
        public void Created_operations_are_wrapped_in_ContinueOnFailure_behavior(IOperationResolver resolver)
        {
            var sut = new WorkflowConfiguration<TestOperation>() { Resolver = resolver };

            var result = sut.CreateOperation();

            Assert.IsType<ContinueOnFailureBehavior>(result);
        }
        public void You_can_create_an_operation_from_the_configuration(IOperationResolver resolver)
        {
            var sut = new WorkflowConfiguration<TestOperation>() { Resolver = resolver };

            var result = sut.CreateOperation();

            Assert.NotNull(result);
        }
Exemple #8
0
 public QueryController(ILogger <QueryController> logger, SqlDbContext sqlDbContext
                        , IConfiguration configuration, IOperationResolver operationResolver)
 {
     _logger            = logger;
     _dbContext         = sqlDbContext;
     _configuration     = configuration;
     _operationResolver = operationResolver;
 }
Exemple #9
0
        public void Fluently_assigning_operation_resolver_returns_configuration(IOperationResolver resolver)
        {
            var sut = new FakeWorkflowConfiguration();

            var result = sut.WithResolver(resolver);

            Assert.Equal(sut, result);
        }
Exemple #10
0
        public void You_can_fluently_assign_the_operation_resolver(IOperationResolver resolver)
        {
            var sut = new FakeWorkflowConfiguration();

            sut.WithResolver(resolver);

            Assert.Equal(resolver, sut.Resolver);
        }
Exemple #11
0
        public void You_can_create_an_operation_from_the_configuration(IOperationResolver resolver)
        {
            var sut = new WorkflowConfiguration <TestOperation>()
            {
                Resolver = resolver
            };

            var result = sut.CreateOperation();

            Assert.NotNull(result);
        }
Exemple #12
0
        public void Created_operations_are_wrapped_in_ContinueOnFailure_behavior(IOperationResolver resolver)
        {
            var sut = new WorkflowConfiguration <TestOperation>()
            {
                Resolver = resolver
            };

            var result = sut.CreateOperation();

            Assert.IsType <ContinueOnFailureBehavior>(result);
        }
Exemple #13
0
        /// <summary>
        /// IQ# Magic that checks that the reference implementation of a Kata's test runs successfully.
        /// </summary>
        public CheckKataMagic(IOperationResolver resolver, ICompilerService compiler, ILogger <KataMagic> logger)
        {
            this.Name          = $"%check_kata";
            this.Documentation = new Documentation()
            {
                Summary = "Checks the resference implementaiton of a single kata's test."
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Compiler = compiler;
            this.Logger   = logger;
        }
Exemple #14
0
        /// <summary>
        /// IQ# Magic that enables executing the Katas on Jupyter.
        /// </summary>
        public KataMagic(IOperationResolver resolver, ISnippets snippets, ILogger <KataMagic> logger)
        {
            this.Name          = $"%kata";
            this.Documentation = new Documentation()
            {
                Summary = "Executes a single kata.", Full = "## Executes a single kata.\n##Usage: \n%kata Test \"q# operation\""
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Snippets = snippets;
            this.Logger   = logger;
        }
Exemple #15
0
 /// <summary>
 /// Creates a SymbolResolver from a Snippets implementation. Only used for testing.
 /// </summary>
 internal SymbolResolver(Snippets snippets)
 {
     this.opsResolver = new OperationResolver(snippets);
 }
Exemple #16
0
 /// <summary>
 ///     Constructs a new resolver that looks for symbols in a given
 ///     collection of snippets.
 /// </summary>
 /// <param name="opsResolver">
 ///     An object to be used to resolve operation names to symbols.
 /// </param>
 public SymbolResolver(IOperationResolver opsResolver)
 {
     this.opsResolver = opsResolver;
 }
 public DefaultExecutionPlan(IPersistenceProvider persistenceProvider, IOperationResolver operationResolver)
 {
     this.persistenceProvider = persistenceProvider;
     this.operationResolver = operationResolver;
 }
 /// <summary>
 /// Create a new FakeOperationResolver instance.
 /// </summary>
 /// <param name="innerOperationResolver">An implementation of the IOperationResolver which the resolver
 /// falls back to whenever a requested operation type does not have a fake instance registered. Defaults
 /// to the SimpleOperationResolver class.</param>
 /// <param name="applyBehaviors">Whether to apply behaviors to fake operations before returning them.
 /// Since the behaviors are seldom relevant for testing, this is turned off by default. Behaviors are
 /// still applied to operations with no fakes registered for them.</param>
 public FakeOperationResolver(IOperationResolver innerOperationResolver = null, bool applyBehaviors = false)
 {
     _applyBehaviors = applyBehaviors;
     _innerResolver  = innerOperationResolver ?? new SimpleOperationResolver();
 }
Exemple #19
0
 /// <summary>
 /// Creates a SymbolResolver from a Snippets implementation. Only used for testing.
 /// </summary>
 internal SymbolResolver(Snippets snippets)
 {
     this.opsResolver = new OperationResolver(snippets, snippets.Workspace, snippets.GlobalReferences);
 }
        public void You_can_create_operation_with_a_configuration_containing_a_resolver(IOperationResolver resolver)
        {
            var correctConfiguration = new FakeWorkflowConfiguration {
                Resolver = resolver
            };

            var result = Operation.Create <TestOperation>(correctConfiguration);

            Assert.NotNull(result);
        }
        public SymbolResolver(IOperationResolver opsResolver, IEventService eventService)
        {
            this.opsResolver = opsResolver;

            eventService?.TriggerServiceInitialized <ISymbolResolver>(this);
        }