Exemplo n.º 1
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.cache      = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();
            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(), this.cache, null)
            {
                Container = this.siteDir
            };

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

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

            this.rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null)
            {
                Name = "testRDL", ShortName = "test"
            };
            this.rdl.Scale.Add(testScale);
            var qkf = new QuantityKindFactor();

            this.derivedQuantityKind = new DerivedQuantityKind {
                Name = "derivedQuantityKind", ShortName = "dqk"
            };
            this.derivedQuantityKind.QuantityKindFactor.Add(qkf);
            this.rdl.ParameterType.Add(new SimpleQuantityKind {
                Name = "testSQK", ShortName = "tSQK"
            });
            this.siteDir.SiteReferenceDataLibrary.Add(this.rdl);

            this.cache.TryAdd(new CacheKey(this.rdl.Iid, null), new Lazy <Thing>(() => this.rdl));

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

            this.transaction = new ThingTransaction(transactionContext, null);

            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 DerivedQuantityKindDialogViewModel(this.derivedQuantityKind, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.navigation.Object, null);
        }
Exemplo n.º 2
0
        public void VerifyInspectSelectedDefaultScale()
        {
            var scale1 = new LogarithmicScale(Guid.NewGuid(), null, null);
            var vm     = new DerivedQuantityKindDialogViewModel(this.derivedQuantityKind, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.navigation.Object, this.rdl);

            Assert.IsFalse(vm.InspectSelectedScaleCommand.CanExecute(null));
            vm.SelectedDefaultScale = scale1;
            Assert.IsTrue(vm.InspectSelectedScaleCommand.CanExecute(null));
            vm.InspectSelectedScaleCommand.Execute(null);
            this.navigation.Verify(x => x.Navigate(It.IsAny <MeasurementScale>(), It.IsAny <ThingTransaction>(), this.session.Object, false, ThingDialogKind.Inspect, this.navigation.Object, It.IsAny <Thing>(), null));
        }
Exemplo n.º 3
0
        public void VerifyInspectQuantityKindFactor()
        {
            var vm = new DerivedQuantityKindDialogViewModel(this.derivedQuantityKind, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.navigation.Object, this.rdl);

            Assert.IsNull(vm.SelectedQuantityKindFactor);

            vm.SelectedQuantityKindFactor = vm.QuantityKindFactor.First();
            Assert.IsTrue(vm.InspectQuantityKindFactorCommand.CanExecute(null));
            vm.InspectQuantityKindFactorCommand.Execute(null);
            this.navigation.Verify(x => x.Navigate(It.IsAny <QuantityKindFactor>(), It.IsAny <ThingTransaction>(), this.session.Object, false, ThingDialogKind.Inspect, this.navigation.Object, It.IsAny <Thing>(), null));
        }
Exemplo n.º 4
0
        public void VerifyThatParameterlessContructorExists()
        {
            var dialogViewModel = new DerivedQuantityKindDialogViewModel();

            Assert.IsFalse(dialogViewModel.IsDeprecated);
        }