public void VerifyInspectSelectedDefaultScale() { var scale1 = new LogarithmicScale(Guid.NewGuid(), null, null); var vm = new SimpleQuantityKindDialogViewModel(this.simpleQuantityKind, 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)); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.serviceLocator = new Mock <IServiceLocator>(); this.navigation = new Mock <IThingDialogNavigationService>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingDialogNavigationService>()).Returns(this.navigation.Object); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session = new Mock <ISession>(); var person = new Person(Guid.NewGuid(), null, null) { Container = this.siteDir }; this.session.Setup(x => x.ActivePerson).Returns(person); this.siteDir = new SiteDirectory(Guid.NewGuid(), null, null); this.siteDir.Person.Add(person); this.rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null) { Name = "testRDL", ShortName = "test" }; this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "simpleQuantityKind", ShortName = "cat" }; var cat = new Category(Guid.NewGuid(), null, null) { Name = "category1", ShortName = "cat1" }; cat.PermissibleClass.Add(ClassKind.SimpleQuantityKind); this.rdl.DefinedCategory.Add(cat); this.siteDir.SiteReferenceDataLibrary.Add(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)); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); 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 SimpleQuantityKindDialogViewModel(this.simpleQuantityKind, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, null, null); }