/// <summary>
        /// Constructs a new instance of <see cref="CommandLinePredictorTests" />
        /// </summary>
        public CommandLinePredictorTests(ModelFixture fixture)
        {
            this._fixture = fixture;
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            this._predictor = new CommandLinePredictor(this._fixture.PredictionCollection[startHistory], null);
        }
        /// <summary>
        /// Constructs a new instance of <see cref="CommandLinePredictorTests" />
        /// </summary>
        public CommandLinePredictorTests(ModelFixture fixture)
        {
            _fixture   = fixture;
            _azContext = new AzContext();
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            _predictor = new CommandLinePredictor(_fixture.PredictionCollection[startHistory], null, null, _azContext);
        }
        /// <summary>
        /// Constructs a new instance of <see cref="AzPredictorServiceTests"/>
        /// </summary>
        /// <param name="fixture"></param>
        public AzPredictorServiceTests(ModelFixture fixture)
        {
            this._fixture = fixture;
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            this._suggestionsPredictor = new Predictor(this._fixture.PredictionCollection[startHistory], null);
            this._commandsPredictor    = new Predictor(this._fixture.CommandCollection, null);

            this._service = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], this._fixture.CommandCollection);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructs a new instance of <see cref="ModelFixture" />
        /// </summary>
        public ModelFixture()
        {
            var currentLocation  = typeof(ModelFixture).Assembly.Location;
            var fileInfo         = new FileInfo(currentLocation);
            var directory        = fileInfo.DirectoryName;
            var dataDirectory    = Path.Join(directory, ModelFixture.DataDirectoryName);
            var commandsModel    = ModelFixture.ReadZipEntry(Path.Join(dataDirectory, ModelFixture.CommandsModelZip), ModelFixture.CommandsModelJson);
            var predictionsModel = ModelFixture.ReadZipEntry(Path.Join(dataDirectory, ModelFixture.PredictionsModelZip), ModelFixture.PredictionsModelJson);

            this.CommandCollection    = JsonSerializer.Deserialize <IList <string> >(commandsModel, JsonUtilities.DefaultSerializerOptions);
            this.PredictionCollection = JsonSerializer.Deserialize <IDictionary <string, IList <string> > >(predictionsModel, JsonUtilities.DefaultSerializerOptions);
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs a new instance of <see cref="AzPredictorTests"/>
        /// </summary>
        public AzPredictorTests(ModelFixture modelFixture)
        {
            this._fixture = modelFixture;
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            this._service         = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], this._fixture.CommandCollection);
            this._telemetryClient = new MockAzPredictorTelemetryClient();
            this._azPredictor     = new AzPredictor(this._service, this._telemetryClient, new Settings()
            {
                SuggestionCount = 1,
            },
                                                    null);
        }
Esempio n. 6
0
        /// <summary>
        /// Constructs a new instance of <see cref="AzPredictorTests"/>
        /// </summary>
        public AzPredictorTests(ModelFixture modelFixture)
        {
            _fixture = modelFixture;
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            _service         = new MockAzPredictorService(startHistory, _fixture.PredictionCollection[startHistory], _fixture.CommandCollection, null);
            _telemetryClient = new MockAzPredictorTelemetryClient();
            _azPredictor     = new AzPredictor(_service, _telemetryClient, new Settings()
            {
                SuggestionCount            = 1,
                MaxAllowedCommandDuplicate = 1,
            },
                                               null);
        }
Esempio n. 7
0
        /// <summary>
        /// Constructs a new instance of <see cref="AzPredictorServiceTests"/>
        /// </summary>
        /// <param name="fixture"></param>
        public AzPredictorServiceTests(ModelFixture fixture)
        {
            this._fixture = fixture;
            var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";

            this._commandBasedPredictor = new CommandLinePredictor(this._fixture.PredictionCollection[startHistory], null);
            this._fallbackPredictor     = new CommandLinePredictor(this._fixture.CommandCollection, null);

            this._service = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], this._fixture.CommandCollection);

            this._noFallbackPredictorService     = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], null);
            this._noCommandBasedPredictorService = new MockAzPredictorService(null, null, this._fixture.CommandCollection);
            this._noPredictorService             = new MockAzPredictorService(null, null, null);
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs a new instance of <see cref="ModelFixture" />
        /// </summary>
        public ModelFixture()
        {
            var currentLocation          = typeof(ModelFixture).Assembly.Location;
            var fileInfo                 = new FileInfo(currentLocation);
            var directory                = fileInfo.DirectoryName;
            var dataDirectory            = Path.Join(directory, ModelFixture.DataDirectoryName);
            var commandsModelVersions    = JsonSerializer.Deserialize <IDictionary <Version, IList <ModelEntry> > >(ModelFixture.ReadZipEntry(Path.Join(dataDirectory, ModelFixture.CommandsModelZip), ModelFixture.CommandsModelJson), JsonUtilities.DefaultSerializerOptions);
            var predictionsModelVersions = JsonSerializer.Deserialize <IDictionary <Version, Dictionary <string, IList <ModelEntry> > > >(ModelFixture.ReadZipEntry(Path.Join(dataDirectory, ModelFixture.PredictionsModelZip), ModelFixture.PredictionsModelJson), JsonUtilities.DefaultSerializerOptions);

            var commandsModel    = commandsModelVersions[CommandsVersionToUse];
            var predictionsModel = predictionsModelVersions[PredictionsVersionToUse];

            this.CommandCollection = commandsModel.Select(x => x.TransformEntry()).ToList();
            var predictiveCollection = new Dictionary <string, IList <PredictiveCommand> >();

            foreach (var command in predictionsModel)
            {
                var predictiveCommandEntries = new List <PredictiveCommand>();
                foreach (var modelEntry in command.Value)
                {
                    predictiveCommandEntries.Add(modelEntry.TransformEntry());
                }
                predictiveCollection.Add(command.Key, predictiveCommandEntries);
            }
            this.PredictionCollection = predictiveCollection;
        }
Esempio n. 9
0
 /// <summary>
 /// Constructs a new instance of <see cref="AzPredictorTelemetryTests"/>
 /// </summary>
 public AzPredictorTelemetryTests(ModelFixture modelFixture)
 {
     _fixture = modelFixture;
 }