public void VerifyCreateWithoutContainerUpdateValidation() { this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.IsAny <SimpleQuantityKind>())).Returns(this.simpleQuantityKindMetaInfo); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.IsAny <string>())).Returns(this.thingMetaInfo); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.Is <string>(y => y == SimpleQuantityKindTypeString))).Returns(this.simpleQuantityKindMetaInfo); var newSimpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), 0) { Alias = new List <Guid>(), Definition = new List <Guid>(), HyperLink = new List <Guid>(), PossibleScale = new List <Guid>(), Name = TestName, ShortName = TestShortName, Symbol = "testSymbol" }; var postOperation = new CdpPostOperation(); postOperation.Create.Add(newSimpleQuantityKind); Assert.Throws( typeof(InvalidOperationException), () => this.operationProcessor.ValidateCreateOperations(postOperation, this.fileStore)); }
public void Verify_that_when_the_DefaultScale_is_not_in_the_PossibleScales_a_result_is_returned() { var ratioScale_1 = new RatioScale { Iid = Guid.Parse("9fd6eb4f-5fb8-469f-8798-20bf4dd84e95"), ShortName = "scale_1" }; var ratioScale_2 = new RatioScale { Iid = Guid.Parse("eed266d7-3ce5-4117-8ca4-2db316ec9cc6"), ShortName = "scale_2" }; var ratioScale_3 = new RatioScale { Iid = Guid.Parse("918abf39-87af-4305-91e8-28c17ab274b2"), ShortName = "scale_3" }; var sqk = new SimpleQuantityKind(); sqk.PossibleScale.Add(ratioScale_1); sqk.PossibleScale.Add(ratioScale_2); sqk.DefaultScale = ratioScale_3; var result = this.quantityKindRuleChecker.ChecksWhetherReferencedDefaultScaleIsInTheCollectionOfPossibleScales(sqk).Single(); Assert.That(result.Id, Is.EqualTo("MA-0750")); Assert.That(result.Description, Is.EqualTo("The QuantityKind.DefaultScale 918abf39-87af-4305-91e8-28c17ab274b2:scale_3 is not in the list of QuantityKind.PossibleScale")); Assert.That(result.Thing, Is.EqualTo(sqk)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error)); }
public async Task VerifyThatParameterGetsCreatedWhenParameterTypeIsDropped() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); elementDefinition.Owner = domainOfExpertise; var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); elementDefinition.ParameterGroup.Add(parameterGroup); var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null); row.ThingCreator = this.thingCreator.Object; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri); var ratioScale = new RatioScale(Guid.NewGuid(), null, null); simpleQuantityKind.DefaultScale = ratioScale; var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); await row.Drop(dropInfo.Object); this.thingCreator.Verify(x => x.CreateParameter(elementDefinition, parameterGroup, simpleQuantityKind, ratioScale, domainOfExpertise, this.session.Object)); }
public void VerifyThatNewParameterTypeDragOverSetsCopyEffect() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); elementDefinition.Owner = domainOfExpertise; var parameterGroup = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); elementDefinition.ParameterGroup.Add(parameterGroup); this.iteration.Element.Add(elementDefinition); var row = new ParameterGroupRowViewModel(parameterGroup, domainOfExpertise, this.session.Object, null); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri); var ratioScale = new RatioScale(Guid.NewGuid(), null, null); simpleQuantityKind.DefaultScale = ratioScale; this.srdl.ParameterType.Add(simpleQuantityKind); var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); row.DragOver(dropInfo.Object); Assert.AreEqual(DragDropEffects.Copy, dropInfo.Object.Effects); }
public void SetUp() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary <CDP4Common.Types.CacheKey, Lazy <Thing> >(); this.ratioScale = new RatioScale(Guid.NewGuid(), this.cache, this.uri); var valuedefLow = new EnumerationValueDefinition(Guid.NewGuid(), this.cache, this.uri); valuedefLow.ShortName = "low"; var valuedefMedium = new EnumerationValueDefinition(Guid.NewGuid(), this.cache, this.uri); valuedefMedium.ShortName = "medium"; this.booleanParameterType = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri); this.dateParameterType = new DateParameterType(Guid.NewGuid(), this.cache, this.uri); this.dateTimeParameterType = new DateTimeParameterType(Guid.NewGuid(), this.cache, this.uri); this.enumerationParameterType = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri); this.enumerationParameterType.Name = "test"; this.enumerationParameterType.ValueDefinition.Add(valuedefLow); this.enumerationParameterType.ValueDefinition.Add(valuedefMedium); this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); this.simpleQuantityKind.PossibleScale.Add(this.ratioScale); this.simpleQuantityKind.DefaultScale = this.ratioScale; this.textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri); this.timeOfDayParameterType = new TimeOfDayParameterType(Guid.NewGuid(), this.cache, this.uri); }
public void VerifyThatPopulatePossibleScalesWorks() { this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri)); var pt = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri) { ShortName = "test" }; this.mrdl.ParameterType.Add(pt); var scale = new RatioScale(Guid.NewGuid(), null, this.uri) { ShortName = "testms" }; this.mrdl.Scale.Add(scale); pt.PossibleScale.Add(scale); var vm = new SimpleParameterValueDialogViewModel(this.parameterValue.Clone(false), this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone); vm.SelectedParameterType = pt; Assert.AreEqual(0, vm.PossibleScale.Count); }
public void VerifyThatPopulateValuesForCompoundParameterTypesWorks() { this.parameterValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri) { ParameterType = null }; this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri)); var valueClone = this.parameterValue.Clone(false); this.requirementClone.ParameterValue.Add(valueClone); var vm = new SimpleParameterValueDialogViewModel(valueClone, this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone); var selectedParameter = new CompoundParameterType(); var parameterTypeComponent = new ParameterTypeComponent(); var selectedSimpleParameter = new SimpleQuantityKind(); parameterTypeComponent.ParameterType = selectedSimpleParameter; selectedParameter.Component.Add(parameterTypeComponent); vm.SelectedParameterType = selectedParameter; Assert.AreEqual(vm.Values.Count, 1); Assert.AreSame(vm.Values.First().ParameterType, selectedParameter); }
public void VerifyThatCompoundParameterOverrideReturnsExpectedModelCodeNoComponent() { var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "l" }; var compoundParameterType = new CompoundParameterType(Guid.NewGuid(), null, null); compoundParameterType.ShortName = "coord"; var component = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = simpleQuantityKind }; component.ShortName = "x"; compoundParameterType.Component.Add(component); this.parameter.ParameterType = compoundParameterType; var parameterOverride = new ParameterOverride { Parameter = this.parameter }; this.elementUsage.ParameterOverride.Add(parameterOverride); Assert.AreEqual("Sat.battery_1.coord", parameterOverride.ModelCode()); }
public void VerifyThatExistingParameterTypeDragOverSetsNoneEffectNoPermission() { var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, null); elementDefinition.Owner = domainOfExpertise; var parameterGroup = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup); var row = new ElementDefinitionRowViewModel(this.elementDefinition, this.activeDomain, this.session.Object, null, this.obfuscationService.Object); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null); var ratioScale = new RatioScale(Guid.NewGuid(), null, null); simpleQuantityKind.DefaultScale = ratioScale; this.srdl.ParameterType.Add(simpleQuantityKind); var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); row.DragOver(dropInfo.Object); Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects); }
public void VerifyCreateWithContainerUpdateInUpdatesValidation() { var modelReferenceDataLibraryMetaInfo = new ModelReferenceDataLibraryMetaInfo(); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.IsAny <SimpleQuantityKind>())).Returns(this.simpleQuantityKindMetaInfo); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.IsAny <ModelReferenceDataLibrary>())).Returns(modelReferenceDataLibraryMetaInfo); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.Is <string>(y => y == SimpleQuantityKindTypeString))).Returns(this.simpleQuantityKindMetaInfo); this.mockedMetaInfoProvider.Setup(x => x.GetMetaInfo(It.Is <string>(y => y == "ModelReferenceDataLibrary"))).Returns(modelReferenceDataLibraryMetaInfo); var newSimpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), 0) { Alias = new List <Guid>(), Definition = new List <Guid>(), HyperLink = new List <Guid>(), PossibleScale = new List <Guid>(), Name = TestName, ShortName = TestShortName, Symbol = "testSymbol" }; // simpleQuantityKind container update var modelReferenceDataLibrary = new ClasslessDTO() { { IidKey, Guid.NewGuid() }, { ClasskindKey, ClassKind.ModelReferenceDataLibrary }, { "ParameterType", new[] { newSimpleQuantityKind.Iid } } }; var postOperation = new CdpPostOperation(); postOperation.Create.Add(newSimpleQuantityKind); postOperation.Update.Add(modelReferenceDataLibrary); Assert.DoesNotThrow(() => this.operationProcessor.ValidateCreateOperations(postOperation, this.fileStore)); }
public void VerifyThatParameterTypeNotInChainRdlCannotBeDrop() { this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); var domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, null); elementDefinition.Owner = domainOfExpertise; var parameterGroup = new ParameterGroup(Guid.NewGuid(), null, null); elementDefinition.ParameterGroup.Add(parameterGroup); var row = new ElementDefinitionRowViewModel(this.elementDefinition, this.activeDomain, this.session.Object, null, this.obfuscationService.Object); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null); var ratioScale = new RatioScale(Guid.NewGuid(), null, null); simpleQuantityKind.DefaultScale = ratioScale; var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); row.DragOver(dropInfo.Object); Assert.AreEqual(DragDropEffects.None, dropInfo.Object.Effects); }
public void Verify_that_The_ParameterTypeComponent_has_a_valid_scale() { var scale = new RatioScale(); var textParameterType = new TextParameterType(); var simpleQuantityKind = new SimpleQuantityKind(); this.parameterTypeComponent.Scale = scale; this.parameterTypeComponent.ParameterType = textParameterType; var result = this.parameterTypeComponentRuleChecker.ChecksWhetherTheParameterTypeComponentHasAValidScale(this.parameterTypeComponent).Single(); Assert.That(result.Id, Is.EqualTo("MA-0740")); Assert.That(result.Description, Is.EqualTo("When the referenced ParameterType is a not QuantityKind, the ParameterTypeComponent.Scale must be null")); Assert.That(result.Thing, Is.EqualTo(this.parameterTypeComponent)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error)); this.parameterTypeComponent.Scale = null; this.parameterTypeComponent.ParameterType = simpleQuantityKind; result = this.parameterTypeComponentRuleChecker.ChecksWhetherTheParameterTypeComponentHasAValidScale(this.parameterTypeComponent).Single(); Assert.That(result.Id, Is.EqualTo("MA-0740")); Assert.That(result.Description, Is.EqualTo("When the referenced ParameterType is a QuantityKind, the ParameterTypeComponent.Scale may not be null")); Assert.That(result.Thing, Is.EqualTo(this.parameterTypeComponent)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error)); }
public void SetUp() { var equipments = new Category { ShortName = "EQT", Name = "Equipments" }; var batteries = new Category { ShortName = "BAT", Name = "Batteries" }; this.categories = new List <Category> { equipments, batteries }; var system = new DomainOfExpertise { ShortName = "SYS", Name = "System Engineering" }; var poweer = new DomainOfExpertise { ShortName = "PWR", Name = "Power Engineering" }; this.domains = new List <DomainOfExpertise> { system, poweer }; var mass = new SimpleQuantityKind { Name = "mass", ShortName = "m" }; var lenght = new SimpleQuantityKind { Name = "length", ShortName = "l" }; this.parameterTypes = new List <ParameterType> { mass, lenght }; }
public void VerifyUpdateOkCanExecute() { var constantName = "constant1"; var constantShortName = "c1"; var constant = new Constant(Guid.NewGuid(), null, this.uri) { Name = constantName, ShortName = constantShortName }; var testParameterType = new SimpleQuantityKind(Guid.NewGuid(), null, null); var testScale = new RatioScale(Guid.NewGuid(), null, this.uri); testParameterType.PossibleScale.Add(testScale); constant.ParameterType = testParameterType; constant.Value = new ValueArray <string>(new List <string> { "1" }); this.siteRdl.ParameterType.Add(testParameterType); this.siteRdl.ParameterType.Add(new BooleanParameterType(Guid.NewGuid(), null, null)); var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object); Assert.IsTrue(vm.OkCanExecute); vm.SelectedParameterType = null; Assert.IsFalse(vm.OkCanExecute); vm.SelectedParameterType = testParameterType; Assert.IsTrue(vm.OkCanExecute); vm.Value.First().Value = string.Empty; Assert.IsFalse(vm.OkCanExecute); vm.Value.First().Value = "Not empty value"; Assert.IsTrue(vm.OkCanExecute); }
public void VerifyThatPropertiesAreSet() { var constantName = "constant1"; var constantShortName = "c1"; var constant = new Constant(Guid.NewGuid(), null, this.uri) { Name = constantName, ShortName = constantShortName }; var testParameterType = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri); var testScale = new RatioScale(Guid.NewGuid(), null, this.uri); testParameterType.PossibleScale.Add(testScale); constant.ParameterType = testParameterType; constant.Value = new ValueArray <string>(new List <string> { "1" }); this.siteRdl.ParameterType.Add(testParameterType); this.siteRdl.ParameterType.Add(new BooleanParameterType(Guid.NewGuid(), null, this.uri)); var vm = new ConstantDialogViewModel(constant, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object); Assert.AreEqual(2, vm.PossibleContainer.Count); vm.Container = vm.PossibleContainer.Last(); Assert.AreEqual(constantName, vm.Name); Assert.AreEqual(constantShortName, vm.ShortName); Assert.AreEqual(2, vm.PossibleCategory.Count); Assert.AreEqual(2, vm.PossibleParameterType.Count); Assert.AreEqual(testParameterType, vm.SelectedParameterType); Assert.AreEqual(1, vm.PossibleScale.Count); Assert.AreEqual(testScale, vm.SelectedScale); Assert.IsNotNull(vm.Value); Assert.AreEqual(1, vm.Value.Count); Assert.AreEqual("1", vm.Value.First().Value); }
public void VerifyThatTheConstructorSetsTheProperties() { var shortname = "constantshortname"; var name = "constant name"; var ratioScale = new RatioScale(Guid.NewGuid(), null, this.uri) { Name = "ratio scale", ShortName = "ratioscaleshortname", }; var qk = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri); qk.DefaultScale = ratioScale; var constant = new Constant(Guid.NewGuid(), null, this.uri) { Name = name, ShortName = shortname, ParameterType = qk, Scale = ratioScale }; var constantRowViewModel = new ConstantRowViewModel(constant, this.session.Object, null); Assert.AreEqual(shortname, constantRowViewModel.ShortName); Assert.AreEqual(name, constantRowViewModel.Name); Assert.AreEqual(string.Empty, constantRowViewModel.ContainerRdl); Assert.AreEqual(ratioScale, constantRowViewModel.SelectedScale); }
public void VerifyThatValidatePocoPropertiesAddsMissingScaleError() { var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); simpleQuantityKind.ValidatePoco(); CollectionAssert.Contains(simpleQuantityKind.ValidationErrors, "The PossibleScale property is empty."); }
public void TestGetAllPossibleScale() { var quantityKind = new SimpleQuantityKind(); quantityKind.PossibleScale.Add(new LogarithmicScale()); Assert.AreEqual(1, quantityKind.AllPossibleScale.Count); }
public void SetUp() { this.quantityKindRuleChecker = new QuantityKindRuleChecker(); this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(); this.simpleQuantityKind = new SimpleQuantityKind(); this.siteReferenceDataLibrary.ParameterType.Add(this.simpleQuantityKind); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.permissionService = new Mock <IPermissionService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); 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(), this.cache, null); this.siteDir.Person.Add(person); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null) { Name = "testRDL", ShortName = "test" }; this.compoundPt = new CompoundParameterType { Name = "parameterType", ShortName = "cat" }; this.cat = new Category(Guid.NewGuid(), this.cache, null) { Name = "category1", ShortName = "cat1" }; this.cat.PermissibleClass.Add(ClassKind.CompoundParameterType); this.srdl.DefinedCategory.Add(cat); this.siteDir.SiteReferenceDataLibrary.Add(this.srdl); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary)); this.bpt = new BooleanParameterType(Guid.NewGuid(), this.cache, null); this.cpt = new CompoundParameterType(Guid.NewGuid(), this.cache, null); this.srdl.ParameterType.Add(this.bpt); this.srdl.ParameterType.Add(this.cpt); this.qt = new SimpleQuantityKind(Guid.NewGuid(), this.cache, null); this.srdl.ParameterType.Add(this.qt); this.scale = new OrdinalScale(Guid.NewGuid(), this.cache, null); this.srdl.Scale.Add(this.scale); this.qt.PossibleScale.Add(this.scale); this.cache.TryAdd(new CacheKey(this.srdl.Iid, null), new Lazy <Thing>(() => this.srdl)); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); 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.parameterType = new ParameterTypeComponent(); }
public void VerifyCreateParameterOverride() { var browser = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, this.panelNavigationService.Object, null, null, null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.elementDef.Owner, ElementDefinition = this.elementDef, Container = this.elementDef }; var usageRow = new ElementUsageRowViewModel(elementUsage, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var qk = new SimpleQuantityKind(); var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri) { Container = this.elementDef, ParameterType = qk, Owner = this.elementDef.Owner }; var parameterRow = new ParameterRowViewModel(parameter, this.session.Object, usageRow, false); Assert.IsFalse(browser.CreateOverrideCommand.CanExecute(null)); browser.SelectedThing = parameterRow; Assert.IsTrue(browser.CreateOverrideCommand.CanExecute(null)); browser.CreateOverrideCommand.Execute(parameter); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); browser.SelectedThing = null; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>()), Times.Once); var paramtType = new CompoundParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); paramtType.Component.Add(new ParameterTypeComponent(Guid.NewGuid(), this.assembler.Cache, this.uri) { ParameterType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri), Scale = null }); parameter.ParameterType = paramtType; var elementDefRow = new ElementDefinitionRowViewModel(this.elementDef, this.elementDef.Owner, this.session.Object, null, this.obfuscationService.Object); var parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameter, 0, this.session.Object, null, null, elementDefRow, false); browser.SelectedThing = parameterValueBaseRow; browser.ComputePermission(); browser.CreateOverrideCommand.Execute(null); var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri) { Parameter = parameter, Owner = this.elementDef.Owner }; parameterValueBaseRow = new ParameterComponentValueRowViewModel(parameterOverride, 0, this.session.Object, null, null, usageRow, false); browser.SelectedThing = parameterValueBaseRow; browser.CreateOverrideCommand.Execute(null); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); 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.session = new Mock <ISession>(); 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 rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null) { Name = "testRDL", ShortName = "test" }; this.scaleReferenceQuantityValue = new ScaleReferenceQuantityValue(); var testLogarithmicScale = new LogarithmicScale(Guid.NewGuid(), this.cache, null) { Name = "Test Derived QK", ShortName = "tdqk" }; var simpleQuantityKind = new SimpleQuantityKind(); rdl.ParameterType.Add(simpleQuantityKind); rdl.Scale.Add(testLogarithmicScale); this.siteDir.SiteReferenceDataLibrary.Add(rdl); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); var chainOfContainers = new[] { rdl }; var clone = testLogarithmicScale.Clone(false); this.cache.TryAdd(new CacheKey(testLogarithmicScale.Iid, null), new Lazy <Thing>(() => testLogarithmicScale)); var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir); this.transaction = new ThingTransaction(transactionContext, clone); 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 ScaleReferenceQuantityValueDialogViewModel(this.scaleReferenceQuantityValue, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, clone, chainOfContainers); }
public void SetUp() { this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary<CDP4Common.Types.CacheKey, Lazy<Thing>>(); this.CreateCategories(); this.textParameterType = new TextParameterType(Guid.NewGuid(), this.cache, this.uri) { ShortName = "TXT" }; this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri) {ShortName = "SIMPLE" }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); }
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); }
public void VerifyThatParameterTypeEventsAreCaught() { var textParamType = new TextParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); CDPMessageBus.Current.SendObjectChangeEvent(textParamType, EventKind.Added); Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count); CDPMessageBus.Current.SendObjectChangeEvent(textParamType, EventKind.Removed); Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any()); var booleanParamType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); CDPMessageBus.Current.SendObjectChangeEvent(booleanParamType, EventKind.Added); Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count); CDPMessageBus.Current.SendObjectChangeEvent(booleanParamType, EventKind.Removed); Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any()); var defaultScale = new CyclicRatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { DefaultScale = defaultScale }; CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Added); Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count); CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Removed); Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any()); var specializedQuantityKind = new SpecializedQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { DefaultScale = defaultScale }; CDPMessageBus.Current.SendObjectChangeEvent(specializedQuantityKind, EventKind.Added); Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count); CDPMessageBus.Current.SendObjectChangeEvent(specializedQuantityKind, EventKind.Removed); Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any()); var derivedQuantityKind = new DerivedQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { DefaultScale = defaultScale }; CDPMessageBus.Current.SendObjectChangeEvent(derivedQuantityKind, EventKind.Added); Assert.AreEqual(1, this.ParameterTypesBrowserViewModel.ParameterTypes.Count); CDPMessageBus.Current.SendObjectChangeEvent(derivedQuantityKind, EventKind.Removed); Assert.IsFalse(this.ParameterTypesBrowserViewModel.ParameterTypes.Any()); }
public void VerifyInspectSelectedGeneral() { var simpleQuantityKind = new SimpleQuantityKind(); this.rdl.ParameterType.Add(simpleQuantityKind); var vm = new SpecializedQuantityKindDialogViewModel(this.specializedQuantityKind, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.navigation.Object, this.rdl); Assert.IsNull(vm.SelectedGeneral); Assert.IsFalse(vm.InspectSelectedGeneralCommand.CanExecute(null)); vm.SelectedGeneral = simpleQuantityKind; Assert.IsTrue(vm.InspectSelectedGeneralCommand.CanExecute(null)); vm.InspectSelectedGeneralCommand.Execute(null); this.navigation.Verify(x => x.Navigate(It.IsAny <SimpleQuantityKind>(), It.IsAny <ThingTransaction>(), this.session.Object, false, ThingDialogKind.Inspect, this.navigation.Object, It.IsAny <Thing>(), null)); }
public void SetUp() { this.simpleQuantityKind = new SimpleQuantityKind() { ShortName = "TST", Name = "TEST" }; this.parameter = new Parameter() { ParameterType = this.simpleQuantityKind }; this.nestedParameter = new NestedParameter() { AssociatedParameter = this.parameter }; }
public void VerifyThatThePropertiesAreUpdateWhenParameterTypeIsUpdated() { var rev = typeof(Thing).GetProperty("RevisionNumber"); var rdlshortnamename = "rdl shortname"; var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = rdlshortnamename, }; var ratioScale = new RatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "RatioScale" }; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "simple quantity kind", ShortName = "sqk", DefaultScale = ratioScale, }; rdl.ParameterType.Add(simpleQuantityKind); rdl.BaseQuantityKind.Add(simpleQuantityKind); var parameterTypeRowViewModel = new ParameterTypeRowViewModel(simpleQuantityKind, this.session.Object, null); var updatedName = "updated quantity kind Shortname"; var updatedShortName = "updatedQKShortName"; var updatedScale = "updatedScale"; simpleQuantityKind.ShortName = updatedShortName; simpleQuantityKind.Name = updatedName; rev.SetValue(simpleQuantityKind, 10); CDPMessageBus.Current.SendObjectChangeEvent(simpleQuantityKind, EventKind.Updated); Assert.AreEqual(simpleQuantityKind.ShortName, parameterTypeRowViewModel.ShortName); Assert.AreEqual(simpleQuantityKind.Name, parameterTypeRowViewModel.Name); Assert.IsTrue(parameterTypeRowViewModel.IsBaseQuantityKind); Assert.AreEqual(simpleQuantityKind.DefaultScale.ShortName, parameterTypeRowViewModel.DefaultScale); Assert.AreEqual(simpleQuantityKind.ClassKind.ToString(), parameterTypeRowViewModel.Type); Assert.AreEqual(rdlshortnamename, parameterTypeRowViewModel.ContainerRdl); ratioScale.ShortName = updatedScale; rev.SetValue(ratioScale, 10); CDPMessageBus.Current.SendObjectChangeEvent(ratioScale, EventKind.Updated); Assert.AreEqual(updatedScale, parameterTypeRowViewModel.DefaultScale); }
public void SetUp() { this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary <CDP4Common.Types.CacheKey, Lazy <Thing> >(); this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.systemEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.powerEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.cache, this.uri); this.equipments = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "EQT", Name = "Equipments" }; this.siteReferenceDataLibrary.DefinedCategory.Add(this.equipments); var engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); engineeringModel.Iteration.Add(this.iteration); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.powerEngineering }; elementDefinition.Category.Add(this.equipments); this.iteration.Element.Add(elementDefinition); var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.powerEngineering, ParameterType = this.simpleQuantityKind }; elementDefinition.Parameter.Add(parameter); var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri) { Owner = this.systemEngineering }; parameter.ParameterSubscription.Add(parameterSubscription); this.session = new Mock <ISession>(); this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.systemEngineering); this.parameterSubscriptionBatchService = new ParameterSubscriptionBatchService(); }
public void VerifyThatParticipantWithoutDomainSelectedCannotDropOnElementDefBrowser() { var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null, null, null); var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), this.assembler.Cache, this.uri); var ratioScale = new RatioScale(Guid.NewGuid(), this.assembler.Cache, this.uri); simpleQuantityKind.DefaultScale = ratioScale; var payload = new Tuple <ParameterType, MeasurementScale>(simpleQuantityKind, ratioScale); var dropInfo = new Mock <IDropInfo>(); dropInfo.Setup(x => x.Payload).Returns(payload); dropInfo.SetupProperty(x => x.Effects); vm.DragOver(dropInfo.Object); Assert.AreEqual(dropInfo.Object.Effects, DragDropEffects.None); }