Beispiel #1
0
        public void VerifyReactiveCommandsCanExecuteOnInspectMode()
        {
            var vm = new BasicRdl.ViewModels.CyclicRatioScaleDialogViewModel(this.cyclicRatioScale, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.navigation.Object, this.rdl, null);

            Assert.IsFalse(vm.CreateAliasCommand.CanExecute(null));
            Assert.IsFalse(vm.CreateDefinitionCommand.CanExecute(null));
            Assert.IsFalse(vm.CreateHyperLinkCommand.CanExecute(null));
            Assert.IsFalse(vm.CreateMappingToReferenceScaleCommand.CanExecute(null));
            Assert.IsFalse(vm.CreateValueDefinitionCommand.CanExecute(null));

            vm.SelectedValueDefinition = this.viewmodel.ValueDefinition.First();
            var mtrs  = new MappingToReferenceScale(Guid.NewGuid(), null, null);
            var mtrsr = new MappingToReferenceScaleRowViewModel(mtrs, this.session.Object, null);

            vm.SelectedMappingToReferenceScale = mtrsr;

            Assert.IsTrue(vm.InspectValueDefinitionCommand.CanExecute(null));
            Assert.IsFalse(vm.EditValueDefinitionCommand.CanExecute(null));
            Assert.IsFalse(vm.DeleteValueDefinitionCommand.CanExecute(null));
            Assert.IsTrue(vm.InspectMappingToReferenceScaleCommand.CanExecute(null));
            Assert.IsFalse(vm.EditMappingToReferenceScaleCommand.CanExecute(null));
            Assert.IsFalse(vm.DeleteMappingToReferenceScaleCommand.CanExecute(null));
        }
Beispiel #2
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.navigation           = new Mock <IThingDialogNavigationService>();
            this.permissionService    = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.session = new Mock <ISession>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            var person = new Person(Guid.NewGuid(), null, null)
            {
                Container = this.siteDir
            };

            this.session.Setup(x => x.ActivePerson).Returns(person);

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, null);

            this.siteDir = new SiteDirectory(Guid.NewGuid(), null, null);
            this.siteDir.Person.Add(person);
            var testScale = new LogarithmicScale();

            this.rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null)
            {
                Name = "testRDL", ShortName = "test"
            };
            this.rdl.Unit.Add(simpleUnit);
            this.rdl.Scale.Add(testScale);
            var svd1 = new ScaleValueDefinition(Guid.NewGuid(), null, null)
            {
                Name = "ReferenceSVD", ShortName = "RSVD"
            };
            var svd2 = new ScaleValueDefinition(Guid.NewGuid(), null, null)
            {
                Name = "DependentSVD", ShortName = "DSVD"
            };

            this.cyclicRatioScale = new CyclicRatioScale(Guid.NewGuid(), null, null)
            {
                Name = "ratioScale", ShortName = "dqk", Modulus = "modulus"
            };
            this.cyclicRatioScale.ValueDefinition.Add(svd1);
            this.cyclicRatioScale.ValueDefinition.Add(svd2);
            this.rdl.ParameterType.Add(new SimpleQuantityKind {
                Name = "testSQK", ShortName = "tSQK"
            });
            this.siteDir.SiteReferenceDataLibrary.Add(this.rdl);

            var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir);

            this.transaction = new ThingTransaction(transactionContext);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary));

            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());

            this.viewmodel = new BasicRdl.ViewModels.CyclicRatioScaleDialogViewModel(this.cyclicRatioScale, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.navigation.Object);
        }