public static void LoadTestFile() { // Load Resource var assemblyExec = Assembly.GetExecutingAssembly(); var resourceName = BasePath + ".Test_Data.GrampsView Test Basic.gpkg"; DataStore.Instance.AD.CurrentInputStream = assemblyExec.GetManifestResourceStream(resourceName); DataStore.Instance.AD.CurrentInputStreamPath = "Test Data/Test_Data.GrampsView Test Basic.gpkg"; // Remove the old dateTime stamps so the files get reloaded even if they have been seen // before TODO CommonLocalSettings.SetReloadDatabase(); GeneralData.setupMocks(); // Other setup IMessenger iocEventAggregator = GeneralData.mocEventAggregator.Object; IStoreXML iocExternalStorage = new StoreXML(GeneralData.iocCommonLogging, GeneralData.iocCommonNotifications); IStorePostLoad iocGrampsStorePostLoad = new StorePostLoad(GeneralData.iocCommonLogging, GeneralData.iocCommonNotifications, iocEventAggregator); IGrampsStoreSerial iocGrampsStoreSerial = new GrampsStoreSerial(GeneralData.iocCommonLogging); IStoreFile iocStoreFile = new StoreFile(); DataRepositoryManager newManager = new DataRepositoryManager(GeneralData.iocCommonLogging, GeneralData.iocCommonNotifications, iocEventAggregator, iocExternalStorage, iocGrampsStorePostLoad, iocGrampsStoreSerial, iocStoreFile); StorePostLoad newPostLoad = new StorePostLoad(GeneralData.iocCommonLogging, GeneralData.iocCommonNotifications, iocEventAggregator); //// Clear the repositories in case we had to restart after being interupted. TODO have //// better mock DataStore.Instance.AD.LoadDataStore(); //DataStore.Instance.AD.CurrentDataFolder.Value = new DirectoryInfo(DataStorePath); //if (DataStore.Instance.AD.CurrentDataFolder.Value.Exists) //{ // DataStore.Instance.AD.CurrentDataFolder.Value.Delete(true); //} //DataStore.Instance.AD.CurrentDataFolder.Value.Create(); // Time to start loading the data DataStoreSetup(); DataRepositoryManager.ClearRepositories(); newManager.StartDataLoad(); newPostLoad.LoadXMLUIItems(null); //// 1) UnTar *.GPKG //iocStoreFile.DataStorageInitialiseAsync().ConfigureAwait(false); //newManager.TriggerLoadGPKGFileAsync().ConfigureAwait(false); //// 2) UnZip new data.GRAMPS file //FileInfoEx GrampsFile = StoreFolder.FolderGetFile(Constants.StorageGRAMPSFileName); //DataStore.Instance.CN.DataLogEntryAdd("Later version of Gramps data file found. Loading it into the program").ConfigureAwait(false); //newManager.TriggerLoadGRAMPSFileAsync(false).ConfigureAwait(false); //// 3) Load new data.XML file //FileInfoEx dataXML = StoreFolder.FolderGetFile(Constants.StorageXMLFileName); //DataStore.Instance.CN.DataLogEntryAdd("Later version of Gramps XML data file found. Loading it into the program").ConfigureAwait(false); //// Load the new data //newManager.TriggerLoadGrampsUnZippedFolderAsync().ConfigureAwait(false); //// Fixup the models and hlinks //StorePostLoad myStorePostLoad = new StorePostLoad(iocCommonLogging, iocEventAggregator, iocPlatformSpecific); //myStorePostLoad.LoadXMLUIItems(null); //DataStore.Instance.CN.DataLogHide(); Assert.True(DataStore.Instance.AD.CurrentInputStream != null); }
public static void setupMocks() { /* * Mock Common Logging */ ISharedLogging iocCommonLogging = new SharedLogging(); /* * Mock Common Notifications */ Mock <IErrorNotifications> mockCommonNotifications = new Mock <IErrorNotifications>(); mockCommonNotifications .Setup(x => x.DataLogEntryAdd(It.IsAny <string>())); iocCommonNotifications = mockCommonNotifications.Object; /* * Mock Image Loading */ Mock <IFFImageLoading> mocFFImageLoading = new Mock <IFFImageLoading>(); IFFImageLoading iocFFImageLoading = mocFFImageLoading.Object; /* * Mock Xamarin Essentials */ Mock <IXamarinEssentials> mocXamarinEssentials = new Mock <IXamarinEssentials>(); mocXamarinEssentials .Setup(x => x.FileSystemCacheDirectory) .Returns(Path.GetTempPath()); IXamarinEssentials iocXamarinEssentials = mocXamarinEssentials.Object; /* * Mock Event Aggregator */ Mock <DataLoadXMLEvent> mockedEventDataLoadXMLEvent = new Mock <DataLoadXMLEvent>(); // TODO fix this //mocEventAggregator // .Setup(x => x.Register<DataLoadXMLEvent>()) // .Returns(mockedEventDataLoadXMLEvent.Object); //Mock<DataLoadStartEvent> mockedEventDataLoadStartEvent = new Mock<DataLoadStartEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataLoadStartEvent>()) // .Returns(mockedEventDataLoadStartEvent.Object); //Mock<DataSaveSerialEvent> mockedEventDataSaveSerialEvent = new Mock<DataSaveSerialEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataSaveSerialEvent>()) // .Returns(mockedEventDataSaveSerialEvent.Object); //Mock<DataLoadCompleteEvent> mockedEventDataLoadCompleteEvent = new Mock<DataLoadCompleteEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataLoadCompleteEvent>()) // .Returns(mockedEventDataLoadCompleteEvent.Object); IMessenger iocEventAggregator = mocEventAggregator.Object; /* * Mock Platform specific */ iocPlatformSpecific = mocPlatformSpecific.Object; /* * Configure DataStore */ DataStore.Instance.ES = iocXamarinEssentials; DataStore.Instance.FFIL = iocFFImageLoading; /* * Other setup */ iocExternalStorage = new StoreXML(iocCommonLogging, iocCommonNotifications); iocGrampsStorePostLoad = new StorePostLoad(iocCommonLogging, iocCommonNotifications, iocEventAggregator); iocGrampsStoreSerial = new GrampsStoreSerial(iocCommonLogging); iocStoreFile = new StoreFile(); newManager = new DataRepositoryManager(iocCommonLogging, iocCommonNotifications, iocEventAggregator, iocExternalStorage, iocGrampsStorePostLoad, iocGrampsStoreSerial, iocStoreFile); }