Exemplo n.º 1
0
        public void VerifyThatThePropertiesAreUpdateWhenMeaseurementUnitsIsUpdated()
        {
            var shortName = "simpleunitshortname";
            var name      = "simple unit name";

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                ShortName = shortName,
                Name      = name,
            };

            var measurementUnitRowViewModel = new MeasurementUnitRowViewModel(simpleUnit, this.session.Object, null);

            var updatedShortName = "update simpleunitshortname";
            var updatedName      = "update simple unit name";

            simpleUnit.ShortName = updatedShortName;
            simpleUnit.Name      = updatedName;
            // workaround to modify a read-only field
            var type = simpleUnit.GetType();

            type.GetProperty("RevisionNumber").SetValue(simpleUnit, 50);
            CDPMessageBus.Current.SendObjectChangeEvent(simpleUnit, EventKind.Updated);

            Assert.AreEqual(simpleUnit, measurementUnitRowViewModel.Thing);
            Assert.AreEqual(updatedShortName, measurementUnitRowViewModel.ShortName);
            Assert.AreEqual(updatedName, measurementUnitRowViewModel.Name);
            Assert.AreEqual(string.Empty, measurementUnitRowViewModel.ContainerRdl);
            Assert.AreEqual(ClassKind.SimpleUnit.ToString(), measurementUnitRowViewModel.ClassKind);
        }
        private void Virtualize(UnitSide side, Transform trans, float range, Dictionary <EntityId, SimpleUnit> dic)
        {
            dic.Clear();

            var allies = getAllyUnits(side, trans.position, range, allowDead: false, GetSingleUnitTypes(UnitType.Soldier));

            foreach (var u in allies)
            {
                if (!this.TryGetComponent <BaseUnitHealth.Component>(u.id, out var health) ||
                    !this.TryGetComponent <GunComponent.Component>(u.id, out var gun))
                {
                    continue;
                }

                var simple  = new SimpleUnit();
                var inverse = Quaternion.Inverse(trans.rotation);
                simple.RelativePos = (inverse * (u.pos - trans.position)).ToFixedPointVector3();
                simple.RelativeRot = (u.rot * inverse).ToCompressedQuaternion();
                simple.Health      = health == null ? 0: health.Value.Health;
                // todo calc attack and range from GunComponent;

                //int32 attack = 5;
                //float attack_range = 6;
                dic.Add(u.id, simple);

                this.UpdateSystem.SendEvent(new BaseUnitStatus.ForceState.Event(new ForceStateChange(side, UnitState.Sleep)), u.id);
            }
        }
        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.session           = new Mock <ISession>();

            this.siteDir     = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.siteRdl     = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.derivedUnit = new DerivedUnit(Guid.NewGuid(), this.cache, this.uri);
            this.unit        = new SimpleUnit(Guid.NewGuid(), this.cache, this.uri);

            this.siteRdl.Unit.Add(this.unit);

            this.siteDir.SiteReferenceDataLibrary.Add(this.siteRdl);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.cache.TryAdd(new CacheKey(this.derivedUnit.Iid, null), new Lazy <Thing>(() => this.derivedUnit));
            this.clone = this.derivedUnit.Clone(false);

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

            this.transaction = new ThingTransaction(transactionContext, this.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());
        }
Exemplo n.º 4
0
        public void VerifyThatWhenContainerRdlIsSetAndUnitIsSetPropertiesAreSet()
        {
            var rdlshortnamename = "rdl shortname";

            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri)
            {
                ShortName = rdlshortnamename,
            };

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            rdl.Unit.Add(simpleUnit);

            var ratioscale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                Name      = "ratio scale name",
                ShortName = "ratioscaleshortname"
            };

            ratioscale.Unit = simpleUnit;
            rdl.Scale.Add(ratioscale);

            var measurementScaleRowViewModel = new MeasurementScaleRowViewModel(ratioscale, this.session.Object, null);

            Assert.AreEqual(ratioscale.ShortName, measurementScaleRowViewModel.ShortName);
            Assert.AreEqual(ratioscale.Name, measurementScaleRowViewModel.Name);
            Assert.AreEqual(simpleUnit.ShortName, measurementScaleRowViewModel.MeasurementUnit);
            Assert.AreEqual(rdlshortnamename, measurementScaleRowViewModel.ContainerRdl);
        }
        public void VerifyThatExceptionIsThrownWhenModifiedThingIsNotProvided()
        {
            var simpleUnit = new SimpleUnit(Guid.NewGuid(), 1);
            var operation  = new Operation(simpleUnit, null, OperationKind.Delete);

            Assert.Throws <ArgumentNullException>(() => this.wspPostOperation.ConstructFromOperation(operation));
        }
        public void VerifyThatExceptionIsThrowWhenOperationIsUpdateAndOriginalThingIsNull()
        {
            var simpleUnit = new SimpleUnit(Guid.NewGuid(), 1);
            var operation  = new Operation(null, simpleUnit, OperationKind.Update);

            Assert.Throws <ArgumentException>(() => this.wspPostOperation.ConstructFromOperation(operation));
        }
Exemplo n.º 7
0
        public void VerifyThatUnitsFromExistingRdlsAreLoaded()
        {
            var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);
            var unit1 = new SimpleUnit(Guid.NewGuid(), null, null);
            var unit2 = new SimpleUnit(Guid.NewGuid(), null, null);

            siterefenceDataLibrary.Unit.Add(unit1);
            siterefenceDataLibrary.Unit.Add(unit2);
            this.siteDir.SiteReferenceDataLibrary.Add(siterefenceDataLibrary);

            var engineeringModelSetup     = new EngineeringModelSetup(Guid.NewGuid(), null, null);
            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null);
            var unit3 = new SimpleUnit(Guid.NewGuid(), null, null);
            var unit4 = new SimpleUnit(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.Unit.Add(unit3);
            modelReferenceDataLibrary.Unit.Add(unit4);
            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);
            this.siteDir.Model.Add(engineeringModelSetup);
            this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary)
            {
                modelReferenceDataLibrary
            });

            var browser = new MeasurementUnitsBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null);

            Assert.AreEqual(4, browser.MeasurementUnits.Count);
        }
        public void VerifyThatExceptionIsThrowWhenOperationIsMove()
        {
            var simpleUnit = new SimpleUnit(Guid.NewGuid(), 1);
            var operation  = new Operation(null, simpleUnit, OperationKind.Move);

            Assert.Throws <NotSupportedException>(() => this.wspPostOperation.ConstructFromOperation(operation));
        }
        public void SetUp()
        {
            this.session = new Mock <ISession>();
            var uri     = new Uri("http://rheagroup.com");
            var siteDir = new SiteDirectory(Guid.NewGuid(), null, uri);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(siteDir);
            this.simpleUnit = new SimpleUnit(Guid.NewGuid(), null, uri);

            var transactionContext = TransactionContextResolver.ResolveContext(siteDir);

            this.transaction = new ThingTransaction(transactionContext);

            this.simpleUnitDialogView = new TestView();
            var viewExportAttribute = new ThingDialogViewExportAttribute(ClassKind.SimpleUnit);
            var lazyview            = new Lazy <IThingDialogView, IClassKindMetaData>(() => this.simpleUnitDialogView, viewExportAttribute);

            this.simpleUnitDialogViewModel = new TestViewModel(this.simpleUnit, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, null);
            var viewModelExportAttribute = new ThingDialogViewModelExportAttribute(ClassKind.SimpleUnit);
            var lazyviewmodel            = new Lazy <IThingDialogViewModel, IClassKindMetaData>(() => this.simpleUnitDialogViewModel, viewModelExportAttribute);

            this.lazyviews = new List <Lazy <IThingDialogView, IClassKindMetaData> >();
            this.lazyviews.Add(lazyview);

            this.lazyviewmodels = new List <Lazy <IThingDialogViewModel, IClassKindMetaData> >();
            this.lazyviewmodels.Add(lazyviewmodel);

            this.specialTermService = new SpecialTermsService();
        }
Exemplo n.º 10
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.navigation        = new Mock <IThingDialogNavigationService>();
            this.permissionService = new Mock <IPermissionService>();
            this.session           = new Mock <ISession>();

            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.siteDir     = new SiteDirectory(Guid.NewGuid(), null, this.uri);
            this.siteRdl     = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri);
            this.derivedUnit = new DerivedUnit(Guid.NewGuid(), null, this.uri);
            this.factor      = new UnitFactor(Guid.NewGuid(), null, this.uri);
            this.derivedUnit.UnitFactor.Add(this.factor);
            this.unit = new SimpleUnit(Guid.NewGuid(), null, this.uri);
            this.siteRdl.Unit.Add(this.unit);
            this.factor.Unit = this.unit;

            this.siteDir.SiteReferenceDataLibrary.Add(this.siteRdl);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary));

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

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

            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());
        }
Exemplo n.º 11
0
 public void SetUp()
 {
     Waffle = new SimpleUnit("waffle");
     Egg = new SimpleUnit("egg");
     Egg.ForwardOperation = new UnitRatioConversion(Egg, Waffle, 1, 2);
     Chicken = new SimpleUnit("chicken");
     Chicken.ForwardOperation = new UnitScalarConversion(Chicken, Egg, 6);
 }
Exemplo n.º 12
0
 public void SetUp()
 {
     Waffle = new SimpleUnit("waffle");
     Egg    = new SimpleUnit("egg");
     Egg.ForwardOperation = new UnitRatioConversion(Egg, Waffle, 1, 2);
     Chicken = new SimpleUnit("chicken");
     Chicken.ForwardOperation = new UnitScalarConversion(Chicken, Egg, 6);
 }
        public void Verify_that_IsMeasurementUnitInChainOfRdls_returns_expected_result()
        {
            var simpleUnit = new SimpleUnit();

            Assert.That(this.mRdl.IsMeasurementUnitInChainOfRdls(simpleUnit), Is.False);

            this.sRdl1.Unit.Add(simpleUnit);
            Assert.That(this.mRdl.IsMeasurementUnitInChainOfRdls(simpleUnit), Is.True);
        }
Exemplo n.º 14
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;

            this.uri = new Uri("http://www.rheagroup.com");
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.dialogService     = new Mock <IThingDialogNavigationService>();
            this.cache             = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            var person = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                Container = this.siteDir
            };

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

            this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.siteDir.Person.Add(person);
            this.genericSiteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "Generic RDL", ShortName = "GENRDL"
            };
            this.siteDir.SiteReferenceDataLibrary.Add(this.genericSiteReferenceDataLibrary);

            var gram = new SimpleUnit(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "gram", ShortName = "g"
            };

            this.genericSiteReferenceDataLibrary.Unit.Add(gram);
            var metre = new SimpleUnit(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "metre", ShortName = "m"
            };

            this.genericSiteReferenceDataLibrary.Unit.Add(metre);
            this.cache.TryAdd(new CacheKey(this.siteDir.Iid, null), new Lazy <Thing>(() => this.siteDir));
            this.sitedirclone = this.siteDir.Clone(false);

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

            this.transaction = new ThingTransaction(transactionContext, this.sitedirclone);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            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());
        }
Exemplo n.º 15
0
        public void VerifyThatIfMeasurementUnitIsBaseUnitTheISBaseUnitPropertyIsTrue()
        {
            var rdl        = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri);
            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri);

            rdl.Unit.Add(simpleUnit);
            rdl.BaseUnit.Add(simpleUnit);

            var measurementUnitRowViewModel = new MeasurementUnitRowViewModel(simpleUnit, this.session.Object, null);

            Assert.IsTrue(measurementUnitRowViewModel.IsBaseUnit);
        }
Exemplo n.º 16
0
        public void Verify_that_when_referenced_MeasurementUnit_is_in_chain_of_rdls_no_result_is_returned()
        {
            var unit = new SimpleUnit {
                Iid = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"), ShortName = "SIMPLE"
            };

            this.siteReferenceDataLibrary.Unit.Add(unit);

            this.linearConversionUnit.ReferenceUnit = unit;

            var results = this.conversionBasedUnitRuleChecker.CheckWhetherReferencedMeasurementUnitIsInChainOfRdls(this.linearConversionUnit);

            Assert.That(results, Is.Empty);
        }
        public void Verify_that_QueryMeasurementUnitsFromChainOfRdls_returns_expected_result()
        {
            var mRdl_MeasurementUnit   = new SimpleUnit(Guid.NewGuid(), null, null);
            var sRdl1_MeasurementUnit  = new SimpleUnit(Guid.NewGuid(), null, null);
            var sRdl11_MeasurementUnit = new SimpleUnit(Guid.NewGuid(), null, null);

            this.mRdl.Unit.Add(mRdl_MeasurementUnit);
            this.sRdl1.Unit.Add(sRdl1_MeasurementUnit);
            this.sRdl11.Unit.Add(sRdl11_MeasurementUnit);

            Assert.That(new List <MeasurementUnit> {
                mRdl_MeasurementUnit, sRdl1_MeasurementUnit, sRdl11_MeasurementUnit
            }, Is.EquivalentTo(this.mRdl.QueryMeasurementUnitsFromChainOfRdls()));
        }
        public void Verify_that_when_referenced_DeprecatableThing_Is_not_Deprecated_no_result_is_returned()
        {
            var unit = new SimpleUnit()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "SIMPLE",
                IsDeprecated = false
            };

            this.ratioScale.Unit = unit;

            var results = this.measurementScaleRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.ratioScale);

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 19
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_not_Deprecated_no_result_is_returned()
        {
            var unit = new SimpleUnit()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "SIMPLE",
                IsDeprecated = false
            };

            this.linearConversionUnit.ReferenceUnit = unit;

            var results = this.conversionBasedUnitRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.linearConversionUnit);

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 20
0
        public void VerifyThatTheConstructorSetsTheProperties()
        {
            var rdl        = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri);
            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            var measurementUnitRowViewModel = new MeasurementUnitRowViewModel(simpleUnit, this.session.Object, null);

            Assert.AreEqual(simpleUnit.ShortName, measurementUnitRowViewModel.ShortName);
            Assert.AreEqual(simpleUnit.Name, measurementUnitRowViewModel.Name);
            Assert.AreEqual(string.Empty, measurementUnitRowViewModel.ContainerRdl);
        }
        public void Verify_that_when_DeprecatableThing_Is_Deprecated_no_result_is_returned()
        {
            var unit = new SimpleUnit()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "SIMPLE",
                IsDeprecated = true
            };

            this.unitFactor.Unit          = unit;
            this.derivedUnit.IsDeprecated = true;

            var results = this.unitFactorRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.unitFactor);

            Assert.That(results, Is.Empty);
        }
Exemplo n.º 22
0
        public void VerifyThatThePropertiesAreUpdateWhenMeaseurementScaleIsUpdated()
        {
            var rdlshortnamename = "rdl shortname";

            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri)
            {
                ShortName = rdlshortnamename,
            };

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            rdl.Unit.Add(simpleUnit);

            var ratioscale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                Name      = "ratio scale name",
                ShortName = "ratioscaleshortname"
            };

            ratioscale.Unit = simpleUnit;

            rdl.Scale.Add(ratioscale);

            var measurementScaleRowViewModel = new MeasurementScaleRowViewModel(ratioscale, this.session.Object, null);

            var updatedShortName = "updated scaleshortname";
            var updatedName      = "updated scale name";

            ratioscale.ShortName = updatedShortName;
            ratioscale.Name      = updatedName;
            // workaround to modify a read-only field
            var type = ratioscale.GetType();

            type.GetProperty("RevisionNumber").SetValue(ratioscale, 50);
            CDPMessageBus.Current.SendObjectChangeEvent(ratioscale, EventKind.Updated);

            Assert.AreEqual(ratioscale.ShortName, measurementScaleRowViewModel.ShortName);
            Assert.AreEqual(ratioscale.Name, measurementScaleRowViewModel.Name);
            Assert.AreEqual(simpleUnit.ShortName, measurementScaleRowViewModel.MeasurementUnit);
            Assert.AreEqual(rdlshortnamename, measurementScaleRowViewModel.ContainerRdl);
        }
Exemplo n.º 23
0
        public void VerifyThatSimpleUnitIsAddedAndRemovedWhenItIsSentAsAObjectChangeMethod()
        {
            Assert.IsFalse(this.measurementUnitsViewModel.MeasurementUnits.Any());

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            CDPMessageBus.Current.SendObjectChangeEvent(simpleUnit, EventKind.Added);
            Assert.AreEqual(1, this.measurementUnitsViewModel.MeasurementUnits.Count);

            Assert.IsTrue(this.measurementUnitsViewModel.MeasurementUnits.Any(x => x.Thing == simpleUnit));

            CDPMessageBus.Current.SendObjectChangeEvent(simpleUnit, EventKind.Removed);
            Assert.IsFalse(this.measurementUnitsViewModel.MeasurementUnits.Any(x => x.Thing == simpleUnit));
        }
Exemplo n.º 24
0
        public void Verify_that_when_referenced_MeasurementUnit_is_not_in_chain_of_rdls_result_is_returned()
        {
            var unit = new SimpleUnit {
                Iid = Guid.Parse("1191838a-0f9f-4d2c-8369-cf729d281dee"), ShortName = "SIMPLE"
            };
            var otherSiterReferenceDataLibrary = new SiteReferenceDataLibrary();

            otherSiterReferenceDataLibrary.Unit.Add(unit);

            this.linearConversionUnit.ReferenceUnit = unit;

            var first = this.conversionBasedUnitRuleChecker.CheckWhetherReferencedMeasurementUnitIsInChainOfRdls(this.linearConversionUnit).First();

            Assert.That(first.Id, Is.EqualTo("MA-0240"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementUnit 1191838a-0f9f-4d2c-8369-cf729d281dee:SIMPLE of ConversionBasedUnit.ReferenceUnit is not in the chain of Reference Data Libraries"));
            Assert.That(first.Thing, Is.EqualTo(this.linearConversionUnit));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Error));
        }
Exemplo n.º 25
0
        public void VerifyThatPropertiesAreSet()
        {
            var shortname    = "new shortname";
            var name         = "new name";
            var isdeprecated = true;

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, null);
            var vm         = new SimpleUnitDialogViewModel(simpleUnit, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object, this.genericSiteReferenceDataLibrary);

            Assert.IsFalse(vm.OkCommand.CanExecute(null));

            vm.ShortName    = shortname;
            vm.Name         = name;
            vm.IsDeprecated = isdeprecated;
            vm.Container    = this.genericSiteReferenceDataLibrary;

            Assert.IsTrue(vm.OkCommand.CanExecute(null));
        }
Exemplo n.º 26
0
        /// <summary>
        /// Serialize the <see cref="SimpleUnit"/>
        /// </summary>
        /// <param name="simpleUnit">The <see cref="SimpleUnit"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(SimpleUnit simpleUnit)
        {
            var jsonObject = new JObject();

            jsonObject.Add("alias", this.PropertySerializerMap["alias"](simpleUnit.Alias.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), simpleUnit.ClassKind)));
            jsonObject.Add("definition", this.PropertySerializerMap["definition"](simpleUnit.Definition.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](simpleUnit.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](simpleUnit.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](simpleUnit.HyperLink.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](simpleUnit.Iid));
            jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](simpleUnit.IsDeprecated));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](simpleUnit.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](simpleUnit.Name));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](simpleUnit.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](simpleUnit.ShortName));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](simpleUnit.ThingPreference));
            return(jsonObject);
        }
Exemplo n.º 27
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);
            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.ratioScale = new RatioScale(Guid.NewGuid(), null, null) { Name = "ratioScale", ShortName = "dqk" };
            this.ratioScale.ValueDefinition.Add(svd1);
            this.ratioScale.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, 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 RatioScaleDialogViewModel(this.ratioScale, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.navigation.Object);
        }
        private void VirtualizeUnits(ref VirtualArmy.Component army, Transform trans, List <EntityId> followers)
        {
            UnityEngine.Profiling.Profiler.BeginSample("VirtualizeUnits");
            army.IsActive = true;
            var units = army.SimpleUnits;

            units.Clear();

            var inverse = Quaternion.Inverse(trans.rotation);
            var pos     = trans.position;

            foreach (var id in followers)
            {
                Transform t = null;
                if (TryGetComponentObject(id, out t) == false)
                {
                    continue;
                }

                Rigidbody r = null;
                if (TryGetComponentObject(id, out r))
                {
                    r.Sleep();
                }

                var simple = new SimpleUnit();

                simple.RelativePos = (inverse * (t.position - pos)).ToFixedPointVector3();
                simple.RelativeRot = (t.rotation * inverse).ToCompressedQuaternion();

                units.Add(id, simple);

                SendSleepOrder(id, SleepOrderType.Sleep);
            }

            army.SimpleUnits = units;
            var inter = IntervalCheckerInitializer.InitializedChecker(MovementDictionary.AlarmInter);

            UpdateLastChecked(ref inter);
            army.AlarmInter = inter;
            UnityEngine.Profiling.Profiler.EndSample();
        }
Exemplo n.º 29
0
        public void Verify_that_when_referenced_DeprecatableThing_Is_Deprecated_result_is_returned()
        {
            var unit = new SimpleUnit()
            {
                Iid          = Guid.Parse("7f1bacf8-9517-44d1-aead-6cf9c3027db7"),
                ShortName    = "SIMPLE",
                IsDeprecated = true
            };

            this.linearConversionUnit.ReferenceUnit = unit;

            var results = this.conversionBasedUnitRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.linearConversionUnit);

            var first = results.First();

            Assert.That(first.Id, Is.EqualTo("MA-0500"));
            Assert.That(first.Description, Is.EqualTo("The referenced MeasurementScale 7f1bacf8-9517-44d1-aead-6cf9c3027db7:SIMPLE of ConversionBasedUnit.ReferenceUnit is deprecated"));
            Assert.That(first.Thing, Is.EqualTo(this.linearConversionUnit));
            Assert.That(first.Severity, Is.EqualTo(SeverityKind.Warning));
        }
Exemplo n.º 30
0
        public void VerifyThatThePropertiesAreUpdateWhenMeaseurementUnitIsUpdated()
        {
            var rdlshortnamename = "rdl shortname";

            var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), null, this.uri)
            {
                ShortName = rdlshortnamename,
            };

            var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, this.uri)
            {
                Name      = "simple unit name",
                ShortName = "simpleunitshortname"
            };

            rdl.Unit.Add(simpleUnit);

            var ratioscale = new RatioScale(Guid.NewGuid(), null, this.uri)
            {
                Name      = "ratio scale name",
                ShortName = "ratioscaleshortname"
            };

            ratioscale.Unit = simpleUnit;
            rdl.Scale.Add(ratioscale);

            var measurementScaleRowViewModel = new MeasurementScaleRowViewModel(ratioscale, this.session.Object, null);

            var updatedShortName = "updated scaleshortname";
            var updatedName      = "updated scale name";

            simpleUnit.ShortName = updatedShortName;
            simpleUnit.Name      = updatedName;

            CDPMessageBus.Current.SendObjectChangeEvent(simpleUnit, EventKind.Updated);

            Assert.AreEqual(ratioscale.ShortName, measurementScaleRowViewModel.ShortName);
            Assert.AreEqual(ratioscale.Name, measurementScaleRowViewModel.Name);
            Assert.AreEqual(simpleUnit.ShortName, measurementScaleRowViewModel.MeasurementUnit);
            Assert.AreEqual(rdlshortnamename, measurementScaleRowViewModel.ContainerRdl);
        }
Exemplo n.º 31
0
        private void Virtualize(UnitSide side, Vector3 position, float range, Dictionary <uint, TroopContainer> containers)
        {
            containers.Clear();

            var allies = getAllyUnits(side, position, range, allowDead: false, GetSingleUnitTypes(UnitType.Commander));

            foreach (var u in allies)
            {
                if (!this.TryGetComponent <BaseUnitHealth.Component>(u.id, out var health) ||
                    !this.TryGetComponent <GunComponent.Component>(u.id, out var gun) ||
                    !this.TryGetComponent <BaseUnitStatus.Component>(u.id, out var status))
                {
                    continue;
                }

                var rank = status.Value.Rank;
                if (containers.TryGetValue(rank, out var troop) == false)
                {
                    troop = new TroopContainer()
                    {
                        Rank = rank
                    };
                }

                var dic    = troop.SimpleUnits;
                var simple = new SimpleUnit();
                //var inverse = Quaternion.Inverse(trans.rotation);
                simple.RelativePos = (u.pos - position).ToFixedPointVector3();//(inverse * (u.pos - trans.position)).ToFixedPointVector3();
                simple.RelativeRot = u.rot.ToCompressedQuaternion();
                simple.Health      = health == null ? 0: health.Value.Health;
                // todo calc attack and range from GunComponent;

                //int32 attack = 5;
                //float attack_range = 6;
                dic.Add(u.id, simple);

                troop.SimpleUnits = dic;
                containers[rank]  = troop;
            }
        }