/// <summary> /// Initializes a new instance of the <see cref="DataRepositoryManager"/> class. /// </summary> /// <param name="iocCommonLogging"> /// The ioc common logging. /// </param> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> /// <param name="iocExternalStorage"> /// The ioc external storage. /// </param> /// <param name="iocGrampsStorePostLoad"> /// The ioc gramps store post load. /// </param> /// <param name="iocGrampsStoreSerial"> /// The ioc gramps store serial. /// </param> /// <param name="iocStoreFile"> /// The ioc store file. /// </param> public DataRepositoryManager(ICommonLogging iocCommonLogging, IEventAggregator iocEventAggregator, IGrampsStoreXML iocExternalStorage, IStorePostLoad iocGrampsStorePostLoad, IGrampsStoreSerial iocGrampsStoreSerial, IStoreFile iocStoreFile) { _CL = iocCommonLogging ?? throw new ArgumentNullException(nameof(iocCommonLogging)); localExternalStorage = iocExternalStorage ?? throw new ArgumentNullException(nameof(iocExternalStorage)); localPostLoad = iocGrampsStorePostLoad; localStoreSerial = iocGrampsStoreSerial; localStoreFile = iocStoreFile; _EventAggregator = iocEventAggregator; // Event Handlers //_EventAggregator.GetEvent<AppStartLoadDataEvent>().Subscribe(StartDataLoad, ThreadOption.BackgroundThread); _EventAggregator.GetEvent <DataLoadStartEvent>().Subscribe(StartDataLoad, ThreadOption.BackgroundThread); _EventAggregator.GetEvent <DataSaveSerialEvent>().Subscribe(SerializeRepositoriesAsync, ThreadOption.BackgroundThread); _EventAggregator.GetEvent <DataLoadCompleteEvent>().Subscribe(DataLoadedSetTrue, ThreadOption.BackgroundThread); }
/// <summary> /// Initializes a new instance of the <see cref="DataRepositoryManager"/> class. /// </summary> /// <param name="iocCommonLogging"> /// The ioc common logging. /// </param> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> /// <param name="iocExternalStorage"> /// The ioc external storage. /// </param> /// <param name="iocGrampsStorePostLoad"> /// The ioc gramps store post load. /// </param> /// <param name="iocGrampsStoreSerial"> /// The ioc gramps store serial. /// </param> /// <param name="iocStoreFile"> /// The ioc store file. /// </param> public DataRepositoryManager(ISharedLogging iocCommonLogging, IErrorNotifications iocCommonNotifications, IMessenger iocEventAggregator, IStoreXML iocExternalStorage, IStorePostLoad iocGrampsStorePostLoad, IGrampsStoreSerial iocGrampsStoreSerial, IStoreFile iocStoreFile) { _CL = iocCommonLogging ?? throw new ArgumentNullException(nameof(iocCommonLogging)); _ExternalStorage = iocExternalStorage ?? throw new ArgumentNullException(nameof(iocExternalStorage)); _PostLoad = iocGrampsStorePostLoad; _StoreSerial = iocGrampsStoreSerial; _StoreFile = iocStoreFile; _EventAggregator = iocEventAggregator; _commonNotifications = iocCommonNotifications; // Event Handlers Contract.Assert(_EventAggregator != null); App.Current.Services.GetService <IMessenger>().Register <DataLoadStartEvent>(this, (r, m) => { if (!m.Value) { return; } StartDataLoad(); }); App.Current.Services.GetService <IMessenger>().Register <DataSaveSerialEvent>(this, (r, m) => { if (!m.Value) { return; } SerializeRepositoriesAsync(true); }); App.Current.Services.GetService <IMessenger>().Register <DataLoadCompleteEvent>(this, (r, m) => { if (!m.Value) { return; } DataLoadedSetTrue(); }); }
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); }