public void SetUp()
        {
            var mockRepo = new Mock <ISqlRepository <LinksConfiguration> >();

            ExpectedGetLinks = new List <LinksConfiguration> {
                new LinksConfiguration {
                    Id = 1, LinkEndpoint = "google.com", LinkName = "Google"
                }
            };
            ExpectedLink = new LinksConfiguration {
                Id = 1, LinkEndpoint = "google.com", LinkName = "Google"
            };

            mockRepo.Setup(x => x.GetAll()).Returns(ExpectedGetLinks).Verifiable();

            mockRepo.Setup(x => x.Get(1)).Returns(ExpectedLink).Verifiable();

            mockRepo.Setup(x => x.Update(It.IsAny <LinksConfiguration>())).Returns(true).Verifiable();

            mockRepo.Setup(x => x.Insert(It.IsAny <LinksConfiguration>())).Returns(1).Verifiable();

            mockRepo.Setup(x => x.Delete(It.IsAny <LinksConfiguration>())).Verifiable();

            MockRepo = mockRepo;
            Service  = new LinksConfigurationService(MockRepo.Object);
        }
示例#2
0
        private void MigrateLinks(BoundsControl control, BoundingBox box)
        {
            LinksConfiguration config = EnsureConfiguration(control.LinksConfig);

            config.WireframeMaterial   = box.WireframeMaterial;
            config.WireframeEdgeRadius = box.WireframeEdgeRadius;
            config.WireframeShape      = MigrateWireframeShape(box.WireframeShape);
            config.ShowWireFrame       = box.ShowWireFrame;
            control.LinksConfig        = config;
        }
        private void MigrateLinks(BoundsControl control, BoundingBox box, string configAssetDirectory)
        {
            LinksConfiguration config = ScriptableObject.CreateInstance <LinksConfiguration>();

            config.WireframeMaterial   = box.WireframeMaterial;
            config.WireframeEdgeRadius = box.WireframeEdgeRadius;
            config.WireframeShape      = MigrateWireframeShape(box.WireframeShape);
            config.ShowWireFrame       = box.ShowWireFrame;
            AssetDatabase.CreateAsset(config, GenerateUniqueConfigName(configAssetDirectory, box.gameObject, "LinksConfiguration"));

            control.LinksConfig = config;
        }
        private void MigrateLinks(BoundsControl control, BoundingBox box)
        {
            List <string> propertyPaths = new List <string> {
                "wireframeMaterial", "wireframeEdgeRadius", "wireframeShape", "showWireFrame"
            };
            LinksConfiguration config = EnsureConfiguration(control.gameObject, control.LinksConfig, HasPropertyOverrides(box, propertyPaths));

            config.WireframeMaterial   = box.WireframeMaterial;
            config.WireframeEdgeRadius = box.WireframeEdgeRadius;
            config.WireframeShape      = MigrateWireframeShape(box.WireframeShape);
            config.ShowWireFrame       = box.ShowWireFrame;
            control.LinksConfig        = config;
        }
        public LinksConfigurationDto AddLink(LinksConfigurationDto link)
        {
            var entity = new LinksConfiguration {
                LinkEndpoint = link.LinkEndpoint, LinkName = link.LinkName
            };

            var id     = Repo.Insert(entity);
            var result = Repo.Get(id);

            return(new LinksConfigurationDto {
                Id = result.Id, LinkName = result.LinkName, LinkEndpoint = result.LinkEndpoint
            });
        }
        /// <summary>
        /// Tests configuring every property of bounds control in edit mode
        /// </summary>
        public void TestConfiguration()
        {
            GameObject testCube       = GameObject.CreatePrimitive(PrimitiveType.Cube);
            int        testInstanceId = testCube.GetInstanceID();
            GameObject childSphere    = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            var        collider       = childSphere.AddComponent <BoxCollider>();
            GameObject textObj        = new GameObject();

            textObj.transform.parent = testCube.transform;
            var textMesh = textObj.AddComponent <TextMesh>();

            childSphere.transform.parent = testCube.transform;
            var boundsControl = testCube.AddComponent <BoundsControl>();

            boundsControl.Target                  = childSphere;
            boundsControl.BoundsOverride          = collider;
            boundsControl.CalculationMethod       = BoundsCalculationMethod.ColliderOverRenderer;
            boundsControl.BoundsControlActivation = BoundsControlActivationType.ActivateByProximityAndPointer;
            boundsControl.FlattenAxis             = FlattenModeType.FlattenAuto;
            boundsControl.BoxPadding              = Vector3.one;

            // debug properties
            boundsControl.DebugText = textMesh;
            boundsControl.HideElementsInInspector = false;

            // box display
            List <string>           assetsToDestroy  = new List <string>();
            BoxDisplayConfiguration boxDisplayConfig = ScriptableObject.CreateInstance <BoxDisplayConfiguration>();
            string path = GeneratePath("BoxDisplay", testInstanceId);

            assetsToDestroy.Add(path);
            AssetDatabase.CreateAsset(boxDisplayConfig, path);
            var testMaterial = new Material(Shader.Find("Specular"));

            boxDisplayConfig.BoxMaterial             = testMaterial;
            boxDisplayConfig.BoxGrabbedMaterial      = testMaterial;
            boxDisplayConfig.FlattenAxisDisplayScale = 5.0f;
            boundsControl.BoxDisplayConfig           = boxDisplayConfig;

            // links
            LinksConfiguration linksConfig = ScriptableObject.CreateInstance <LinksConfiguration>();

            path = GeneratePath("Links", testInstanceId);
            assetsToDestroy.Add(path);
            AssetDatabase.CreateAsset(linksConfig, path);
            linksConfig.WireframeMaterial   = testMaterial;
            linksConfig.WireframeEdgeRadius = 1.0f;
            linksConfig.WireframeShape      = WireframeType.Cylindrical;
            linksConfig.ShowWireFrame       = false;
            boundsControl.LinksConfig       = linksConfig;

            // scale handles
            ScaleHandlesConfiguration scaleConfig = ScriptableObject.CreateInstance <ScaleHandlesConfiguration>();

            path = GeneratePath("ScaleHandles", testInstanceId);
            assetsToDestroy.Add(path);
            AssetDatabase.CreateAsset(scaleConfig, path);

            scaleConfig.HandleSlatePrefab          = childSphere;
            scaleConfig.ShowScaleHandles           = true;
            scaleConfig.HandleMaterial             = testMaterial;
            scaleConfig.HandleGrabbedMaterial      = testMaterial;
            scaleConfig.HandlePrefab               = testCube;
            scaleConfig.HandleSize                 = 0.05f;
            scaleConfig.ColliderPadding            = Vector3.one;
            scaleConfig.DrawTetherWhenManipulating = false;
            scaleConfig.HandlesIgnoreCollider      = collider;

            boundsControl.ScaleHandlesConfig = scaleConfig;

            // rotation handles
            RotationHandlesConfiguration rotationHandles = ScriptableObject.CreateInstance <RotationHandlesConfiguration>();

            path = GeneratePath("RotationHandles", testInstanceId);
            assetsToDestroy.Add(path);
            AssetDatabase.CreateAsset(rotationHandles, path);

            rotationHandles.RotationHandlePrefabColliderType = HandlePrefabCollider.Box;
            rotationHandles.ShowRotationHandleForX           = false;
            rotationHandles.ShowRotationHandleForY           = true;
            rotationHandles.ShowRotationHandleForZ           = true;
            rotationHandles.HandleMaterial             = testMaterial;
            rotationHandles.HandleGrabbedMaterial      = testMaterial;
            rotationHandles.HandlePrefab               = childSphere;
            rotationHandles.HandleSize                 = 0.05f;
            rotationHandles.ColliderPadding            = Vector3.zero;
            rotationHandles.DrawTetherWhenManipulating = false;
            rotationHandles.HandlesIgnoreCollider      = collider;

            boundsControl.RotationHandlesConfig = rotationHandles;

            // proximity effect
            ProximityEffectConfiguration proximityConfig = ScriptableObject.CreateInstance <ProximityEffectConfiguration>();

            path = GeneratePath("ProximityEffect", testInstanceId);
            assetsToDestroy.Add(path);
            AssetDatabase.CreateAsset(proximityConfig, path);

            proximityConfig.ProximityEffectActive = true;
            proximityConfig.ObjectMediumProximity = 0.2f;
            proximityConfig.ObjectCloseProximity  = 0.02f;
            proximityConfig.FarScale       = 10.0f;
            proximityConfig.MediumScale    = 3.0f;
            proximityConfig.CloseScale     = 5.0f;
            proximityConfig.FarGrowRate    = 1.0f;
            proximityConfig.MediumGrowRate = 0.1f;
            proximityConfig.CloseGrowRate  = 0.5f;

            boundsControl.HandleProximityEffectConfig = proximityConfig;

            // clean up created assets
            foreach (string assetPath in assetsToDestroy)
            {
                AssetDatabase.DeleteAsset(assetPath);
            }

            // destroy test cube
            Object.DestroyImmediate(testCube);
        }