示例#1
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.tokenSource          = new CancellationTokenSource();
            this.session           = new Mock <ISession>();
            this.mockedDal         = new Mock <IDal>();
            this.fileDialogService = new Mock <IOpenSaveFileDialogService>();
            var openTaskCompletionSource = new TaskCompletionSource <IEnumerable <Thing> >();

            openTaskCompletionSource.SetResult(this.dalOutputs);
            this.mockedDal.Setup(x => x.IsValidUri(It.IsAny <string>())).Returns(true);
            this.mockedDal.Setup(x => x.Open(It.IsAny <Credentials>(), this.tokenSource.Token)).Returns(openTaskCompletionSource.Task);

            this.mockedMetaData = new Mock <IDalMetaData>();
            this.mockedMetaData.Setup(x => x.Name).Returns("MockedDal");
            this.mockedMetaData.Setup(x => x.DalType).Returns(DalType.File);

            this.session.Setup(x => x.DalVersion).Returns(new Version("1.0.0"));

            var dataAccessLayerKinds = new List <Lazy <IDal, IDalMetaData> >();

            dataAccessLayerKinds.Add(new Lazy <IDal, IDalMetaData>(() => this.mockedDal.Object, this.mockedMetaData.Object));

            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);

            this.serviceLocator.Setup(x => x.GetInstance <AvailableDals>())
            .Returns(new AvailableDals(dataAccessLayerKinds));

            this.viewModel = new DataSourceExportViewModel(new List <ISession> {
                this.session.Object
            }, this.fileDialogService.Object);
        }
示例#2
0
        public void VerifyVersionChecks()
        {
            this.viewModel = new DataSourceExportViewModel(new List <ISession> {
                this.session.Object
            }, this.fileDialogService.Object);
            Assert.AreEqual(1, this.viewModel.Versions.Count);

            this.session.Setup(x => x.DalVersion).Returns(new Version("1.1.0"));
            this.viewModel = new DataSourceExportViewModel(new List <ISession> {
                this.session.Object
            }, this.fileDialogService.Object);
            Assert.AreEqual(2, this.viewModel.Versions.Count);

            this.session.Setup(x => x.DalVersion).Returns(new Version("1.2.0"));
            this.viewModel = new DataSourceExportViewModel(new List <ISession> {
                this.session.Object
            }, this.fileDialogService.Object);
            Assert.AreEqual(3, this.viewModel.Versions.Count);
        }
示例#3
0
        /// <summary>
        /// Executes the saving of the session to a JSON zip file.
        /// </summary>
        private void ExecuteSaveSessionCommand()
        {
            var sessionExport = new DataSourceExportViewModel(this.Sessions.Select(x => x.Session), new OpenSaveFileDialogService());

            this.dialogNavigationService.NavigateModal(sessionExport);
        }