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);
        }
Exemple #2
0
        public void SetUp()
        {
            this.scaleReferenceQuantityValueRuleChecker = new ScaleReferenceQuantityValueRuleChecker();

            this.siteReferenceDataLibrary = new SiteReferenceDataLibrary();
            this.logarithmicScale         = new LogarithmicScale {
                Iid = Guid.NewGuid()
            };
            this.scaleReferenceQuantityValue = new ScaleReferenceQuantityValue();

            this.siteReferenceDataLibrary.Scale.Add(this.logarithmicScale);
            this.logarithmicScale.ReferenceQuantityValue.Add(this.scaleReferenceQuantityValue);
        }
Exemple #3
0
        /// <summary>
        /// Serialize the <see cref="ScaleReferenceQuantityValue"/>
        /// </summary>
        /// <param name="scaleReferenceQuantityValue">The <see cref="ScaleReferenceQuantityValue"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ScaleReferenceQuantityValue scaleReferenceQuantityValue)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), scaleReferenceQuantityValue.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](scaleReferenceQuantityValue.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](scaleReferenceQuantityValue.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](scaleReferenceQuantityValue.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](scaleReferenceQuantityValue.ModifiedOn));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](scaleReferenceQuantityValue.RevisionNumber));
            jsonObject.Add("scale", this.PropertySerializerMap["scale"](scaleReferenceQuantityValue.Scale));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](scaleReferenceQuantityValue.ThingPreference));
            jsonObject.Add("value", this.PropertySerializerMap["value"](scaleReferenceQuantityValue.Value));
            return(jsonObject);
        }
Exemple #4
0
        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.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);

            this.domain = new DomainOfExpertise(Guid.NewGuid(), null, null)
            {
                Name = "n", ShortName = "s"
            };
            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();
            var referenceQuantityValue = new ScaleReferenceQuantityValue(Guid.NewGuid(), null, null);

            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.logarithmicScale = new LogarithmicScale(Guid.NewGuid(), null, null)
            {
                Name = "logarithmicScale", ShortName = "dqk"
            };
            referenceQuantityValue.Scale = this.logarithmicScale;

            this.logarithmicScale.ValueDefinition.Add(svd1);
            this.logarithmicScale.ValueDefinition.Add(svd2);
            this.logarithmicScale.ReferenceQuantityValue.Add(referenceQuantityValue);
            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, 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 LogarithmicScaleDialogViewModel(this.logarithmicScale, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.navigation.Object);
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScaleReferenceQuantityValueDialogViewModel"/> class.
 /// </summary>
 /// <param name="scaleReferenceQuantityValue">
 /// The <see cref="ScaleReferenceQuantityValue"/> that is the subject of the current view-model. This is the object
 /// that will be either created, or edited.
 /// </param>
 /// <param name="transaction">
 /// The <see cref="ThingTransaction"/> that contains the log of recorded changes.
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated
 /// </param>
 /// <param name="isRoot">
 /// Assert if this <see cref="ScaleReferenceQuantityValueDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/>
 /// </param>
 /// <param name="dialogKind">
 /// The kind of operation this <see cref="ScaleReferenceQuantityValueDialogViewModel"/> performs
 /// </param>
 /// <param name="thingDialogNavigationService">
 /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>.
 /// </param>
 /// <param name="container">
 /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog
 /// </param>
 /// <param name="chainOfContainers">
 /// The optional chain of containers that contains the <paramref name="container"/> argument
 /// </param>
 public ScaleReferenceQuantityValueDialogViewModel(ScaleReferenceQuantityValue scaleReferenceQuantityValue, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null)
     : base(scaleReferenceQuantityValue, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScaleReferenceQuantityValueRowViewModel"/> class
 /// </summary>
 /// <param name="quantityValue">The <see cref="ScaleReferenceQuantityValue"/> represented</param>
 /// <param name="session">The <see cref="ISession"/></param>
 /// <param name="containerViewModel">The viewmodel that contains this row</param>
 public ScaleReferenceQuantityValueRowViewModel(ScaleReferenceQuantityValue quantityValue, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(quantityValue, session, containerViewModel)
 {
     this.UpdateProperties();
 }
 /// <summary>
 /// Add an Reference Quantity Value row view model to the list of <see cref="ReferenceQuantityValue"/>
 /// </summary>
 /// <param name="referenceQuantityValue">
 /// The <see cref="ReferenceQuantityValue"/> that is to be added
 /// </param>
 private ScaleReferenceQuantityValueRowViewModel AddReferenceQuantityValueRowViewModel(ScaleReferenceQuantityValue referenceQuantityValue)
 {
     return(new ScaleReferenceQuantityValueRowViewModel(referenceQuantityValue, this.Session, this));
 }