public void Arrange()
        {
            _stateStoreMock = new Mock <IStateStore>();

            _sldClientMock = new Mock <ISldClient>();
            _sldClientMock.Setup(sld => sld.ListLearnersForProviderAsync(
                                     It.IsAny <string>(),
                                     It.IsAny <int>(),
                                     It.IsAny <int>(),
                                     It.IsAny <CancellationToken>()))
            .ReturnsAsync(new SldPagedResult <Learner>
            {
                Items = new Learner[0],
                TotalNumberOfItems = 0,
                PageNumber         = 0,
                PageSize           = 0,
                TotalNumberOfPages = 1,
            });

            _providerQueueMock = new Mock <IProviderQueue>();

            _learnerQueueMock = new Mock <ILearnerQueue>();

            _sldDataReceiverMock = new Mock <ISldDataReceiver>();

            _loggerMock = new Mock <ILogger <ChangeProcessor> >();

            _processor = new ChangeProcessor(
                _stateStoreMock.Object,
                _sldClientMock.Object,
                _providerQueueMock.Object,
                _learnerQueueMock.Object,
                _sldDataReceiverMock.Object,
                _loggerMock.Object);
        }
        /// <summary>
        /// Method that abstracts the OnTerminate event handler and allows for the change processor to be terminated
        /// from other call sites in the program.
        /// </summary>
        public void Disconnect()
        {
            //Disconnect the events sink and set the change processor to null
            if (_changeProcessor != null)
            {
                this._changeProcessor.OnExecute -= this._onExecute_Delegate;
                this._changeProcessor.OnTerminate -= this._onTerminate_Delegate;

                this._changeDefinitions = null;
                this._changeDefinition.Delete();
                this._changeDefinition = null;
                this._changeProcessor = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Method that abstracts the OnTerminate event handler and allows for the change processor to be terminated
        /// from other call sites in the program.
        /// </summary>
        public void Disconnect()
        {
            //Disconnect the events sink and set the change processor to null
            if (_changeProcessor != null)
            {
                this._changeProcessor.OnExecute   -= this._onExecute_Delegate;
                this._changeProcessor.OnTerminate -= this._onTerminate_Delegate;

                this._changeDefinitions = null;
                this._changeDefinition.Delete();
                this._changeDefinition = null;
                this._changeProcessor  = null;
            }
        }
        public void Arrange()
        {
            _roatpDataSourceMock = new Mock <IRoatpDataSource>();
            _roatpDataSourceMock.Setup(s => s.GetDataAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new ApprenticeshipProvider[0]);

            _roatpDataReceiverMock = new Mock <IRoatpDataReceiver>();

            _loggerMock = new Mock <ILogger <ChangeProcessor> >();

            _changeProcessor = new ChangeProcessor(
                _roatpDataSourceMock.Object,
                _roatpDataReceiverMock.Object,
                _loggerMock.Object);

            _cancellationToken = new CancellationToken();
        }
Exemple #5
0
        public void Arrange()
        {
            _ukrlpApiClientMock = new Mock <IUkrlpApiClient>();

            _stateStoreMock = new Mock <IStateStore>();
            _stateStoreMock.Setup(store => store.GetStateAsync("LastChecked", It.IsAny <CancellationToken>()))
            .ReturnsAsync("2020-12-17T14:39:00Z");

            _ukrlpDataReceiverMock = new Mock <IUkrlpDataReceiver>();

            _loggerMock = new Mock <ILogger <ChangeProcessor> >();

            _changeProcessor = new ChangeProcessor(
                _ukrlpApiClientMock.Object,
                _stateStoreMock.Object,
                _ukrlpDataReceiverMock.Object,
                _loggerMock.Object);

            _cancellationToken = new CancellationToken();
        }
        /// <summary>
        /// Method that is used to encapsulate a series of actions into a single transaction for the user
        /// to undo or redo.
        /// </summary>
        public void Connect()
        {
            //Establish a reference to the change manager
            _changeManager = _inventorApplication.ChangeManager;

            //Establish a reference to the Change Definitions collection for this add-in
            _changeDefinitions = _changeManager.Add(_clientID);

            _changeDefinition = _changeDefinitions.Add(_changeDefInternalName, _changeDefCommandName);

            //Create a change processor
            _changeProcessor = _changeDefinition.CreateChangeProcessor();

            //Connect the events
            this._onExecute_Delegate = new ChangeProcessorSink_OnExecuteEventHandler(changeProcessor_OnExecute);
            _changeProcessor.OnExecute += this._onExecute_Delegate;

            this._onTerminate_Delegate = new ChangeProcessorSink_OnTerminateEventHandler(changeProcessor_OnTerminate);
            _changeProcessor.OnTerminate += this._onTerminate_Delegate;

            //Calling the Execute method is what causes the transaction to occur.
            _changeProcessor.Execute(_inventorApplication.ActiveEditDocument);
        }
Exemple #7
0
        /// <summary>
        /// Method that is used to encapsulate a series of actions into a single transaction for the user
        /// to undo or redo.
        /// </summary>
        public void Connect()
        {
            //Establish a reference to the change manager
            _changeManager = _inventorApplication.ChangeManager;

            //Establish a reference to the Change Definitions collection for this add-in
            _changeDefinitions = _changeManager.Add(_clientID);

            _changeDefinition = _changeDefinitions.Add(_changeDefInternalName, _changeDefCommandName);

            //Create a change processor
            _changeProcessor = _changeDefinition.CreateChangeProcessor();

            //Connect the events
            this._onExecute_Delegate    = new ChangeProcessorSink_OnExecuteEventHandler(changeProcessor_OnExecute);
            _changeProcessor.OnExecute += this._onExecute_Delegate;

            this._onTerminate_Delegate    = new ChangeProcessorSink_OnTerminateEventHandler(changeProcessor_OnTerminate);
            _changeProcessor.OnTerminate += this._onTerminate_Delegate;

            //Calling the Execute method is what causes the transaction to occur.
            _changeProcessor.Execute(_inventorApplication.ActiveEditDocument);
        }
Exemple #8
0
        public void Arrange()
        {
            _stateStoreMock = new Mock <IStateStore>();

            _sldClientMock = new Mock <ISldClient>();
            _sldClientMock.Setup(sld => sld.ListAcademicYearsAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new[] { "2021" });
            _sldClientMock.Setup(sld => sld.ListProvidersThatHaveSubmittedSinceAsync(
                                     It.IsAny <string>(),
                                     It.IsAny <DateTime?>(),
                                     It.IsAny <int>(),
                                     It.IsAny <CancellationToken>()))
            .ReturnsAsync(new SldPagedResult <int>
            {
                Items = new int[0],
                TotalNumberOfItems = 0,
                PageNumber         = 0,
                PageSize           = 0,
                TotalNumberOfPages = 0,
            });

            _providerQueueMock = new Mock <IProviderQueue>();

            _learnerQueueMock = new Mock <ILearnerQueue>();

            _sldDataReceiverMock = new Mock <ISldDataReceiver>();

            _loggerMock = new Mock <ILogger <ChangeProcessor> >();

            _processor = new ChangeProcessor(
                _stateStoreMock.Object,
                _sldClientMock.Object,
                _providerQueueMock.Object,
                _learnerQueueMock.Object,
                _sldDataReceiverMock.Object,
                _loggerMock.Object);
        }
Exemple #9
0
        public async Task <DafnyDocument> ApplyChangesAsync(DafnyDocument oldDocument, DidChangeTextDocumentParams documentChange, CancellationToken cancellationToken)
        {
            var changeProcessor = new ChangeProcessor(_logger, oldDocument, documentChange.ContentChanges, cancellationToken);
            var mergedItem      = new TextDocumentItem {
                LanguageId = oldDocument.Text.LanguageId,
                Uri        = oldDocument.Uri,
                Version    = documentChange.TextDocument.Version,
                Text       = changeProcessor.MigrateText()
            };
            var loadedDocument = await _documentLoader.LoadAsync(mergedItem, Verify, cancellationToken);

            if (!loadedDocument.SymbolTable.Resolved)
            {
                return(new DafnyDocument(
                           loadedDocument.Text,
                           loadedDocument.Errors,
                           loadedDocument.Program,
                           changeProcessor.MigrateSymbolTable(),
                           // TODO migrate counterexamples?
                           null
                           ));
            }
            return(loadedDocument);
        }