/// <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); }
/// <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; }