コード例 #1
0
        public void ShouldInvokeTheRegisterMethodOfAllIUnityRegistrationTypes()
        {
            //Arrange
            var assembly = Assembly.GetAssembly(typeof(TestUnityRegistration));

            A.CallTo(() => registrationHelper.GetAssemblies())
            .Returns(new List <Assembly> {
                assembly
            });
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly))
            .Returns(new List <Type> {
                typeof(TestUnityRegistration)
            });
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            containerExtension.Run();
            var result = containerExtension.Resolve <UnityExtension>();

            //Assert
            A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened();
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly)).MustHaveHappened();
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(UnityExtension));
        }
コード例 #2
0
        public void Run_WhenTheContainerInOptionsIsSet_ShouldUseTheExistingContainer()
        {
            //Arrange
            var assembly = Assembly.GetAssembly(typeof(TestUnityRegistration));

            A.CallTo(() => registrationHelper.GetAssemblies())
            .Returns(new List <Assembly> {
                assembly
            });
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly))
            .Returns(new List <Type> {
                typeof(TestUnityRegistration)
            });
            var container          = new UnityContainer();
            var containerExtension = new UnityExtension(registrationHelper, options)
            {
                Options = { Container = container }
            };


            //Act
            containerExtension.Run();

            //Assert
            Assert.AreSame(container, containerExtension.Container);
        }
コード例 #3
0
        public void ShouldRegisterAllTypesOfIUnityRegistration()
        {
            //Arrange
            var assembly = Assembly.GetAssembly(typeof(TestUnityRegistration));

            A.CallTo(() => registrationHelper.GetAssemblies())
            .Returns(new List <Assembly> {
                assembly
            });
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly))
            .Returns(new List <Type> {
                typeof(TestUnityRegistration)
            });
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            containerExtension.Run();
            var result = containerExtension.ResolveAll <IUnityRegistration>();

            //Assert
            A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened();
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly)).MustHaveHappened();
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IEnumerable <IUnityRegistration>));
            Assert.IsTrue(result.Count > 0);
        }
コード例 #4
0
        public void ShouldRegisterWithTargetType()
        {
            //Arrange
            var assembly = Assembly.GetAssembly(typeof(RegistrationHelper));

            A.CallTo(() => registrationHelper.GetAssemblies())
            .Returns(new List <Assembly> {
                assembly
            });
            A.CallTo(() => registrationHelper.GetTypesImplementing <IBootstrapperAssemblyProvider>(assembly))
            .Returns(new List <Type> {
                typeof(LoadedAssemblyProvider), typeof(ReferencedAssemblyProvider)
            });
            var container          = new UnityContainer();
            var containerExtension = new UnityExtension(registrationHelper, options);

            containerExtension.InitializeContainer(container);

            //Act
            containerExtension.RegisterAll <IBootstrapperAssemblyProvider>();
            var result = container.ResolveAll <IBootstrapperAssemblyProvider>().ToList();

            //Assert
            A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened();
            A.CallTo(() => registrationHelper.GetTypesImplementing <IBootstrapperAssemblyProvider>(assembly)).MustHaveHappened();
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IEnumerable <IBootstrapperAssemblyProvider>));
            Assert.IsTrue(result.Any());
            Assert.IsTrue(result.Any(c => c is LoadedAssemblyProvider));
            Assert.IsTrue(result.Any(c => c is ReferencedAssemblyProvider));
        }
コード例 #5
0
        public void ShouldRegisterWithConventionAndWithRegistration()
        {
            //Arrange
            var assembly = Assembly.GetAssembly(typeof(TestUnityRegistration));

            A.CallTo(() => registrationHelper.GetAssemblies())
            .Returns(new List <Assembly> {
                assembly
            });
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly))
            .Returns(new List <Type> {
                typeof(TestUnityRegistration)
            });
            var containerExtension = new UnityExtension(registrationHelper, options);

            A.CallTo(() => options.AutoRegistration).Returns(true);

            //Act
            containerExtension.Run();

            //Assert
            A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened();
            A.CallTo(() => registrationHelper.GetTypesImplementing <IUnityRegistration>(assembly)).MustHaveHappened();
            Assert.IsNotNull(containerExtension.Resolve <IRegistrationHelper>());
            Assert.IsNotNull(containerExtension.Resolve <UnityExtension>());
            Assert.IsNotNull(containerExtension.Resolve <IRegisteredByConvention>());
        }
コード例 #6
0
ファイル: EditMode2DR.cs プロジェクト: argul/tri_battle
    public void StartEditCanvas()
    {
        UnityExtension.SetActive(true, editCanvas.gameObject);
        UnityExtension.SetActiveBatch(false, editTraits.gameObject, editMatch.gameObject, editOperation.gameObject);

        ResetCanvas();
    }
コード例 #7
0
    private void TrySelectUnit()
    {
        startPos = Input.mousePosition;
        DoMouseHit(characterLayer);

        if (mouseHit.collider == null)
        {
            DoMouseHit(-1);
            Collider[] units = Physics.OverlapSphere(mouseHit.point, findRadius, characterLayer);
            if (units.Length > 0)
            {
                selected = UnityExtension.GetClosest(mouseHit.point, PController.instance.playerUnits) as CharacterManager;
            }
            else
            {
                return;
            }
        }
        else
        {
            selected = mouseHit.collider.GetComponent <CharacterManager>();
        }
        if (selected == null || selected.GetTeam() != Team.Player1)
        {
            return;
        }
        mousePath.Clear();
        drag = true;
    }
コード例 #8
0
    public void LoadData(List <SlotTrait> colorTraits)
    {
        layout = new ViewLayout2DR(8f, 1f, 8, 1);
        UnityExtension.DestroyAllChildren(cellRoot);
        for (int i = 0; i < traitColors.Length; i++)
        {
            var cell = GameObject.Instantiate(pfbCell);
            var sa   = new SlotAttribute(SlotAttribute.Category.TARGET);
            sa.trait = new SlotTraitColor((byte)(traitColors[i].r * 255),
                                          (byte)(traitColors[i].g * 255),
                                          (byte)(traitColors[i].b * 255),
                                          255);
            cell.Init(sa, layout.CellSize);
            cell.transform.SetParent(cellRoot.transform, layout.Logic2View(new Pos2D(i, 0)), cell.transform.localScale);
            cells[i] = cell;

            foreach (var ct in colorTraits)
            {
                if (sa.trait.AbsoluteEqual(ct))
                {
                    cell.SetSelected(true);
                }
            }
        }
    }
コード例 #9
0
        public float GetContentScale()
        {
            var areaSize = Responsive.GetAreaSizeByMode(AreaMode.Safe);
            var baseSize = Responsive.GetAreaSizeByMode(AreaMode.Viewport);
            var scale    = UnityExtension.GetScaleOfAreaSize(areaSize, baseSize);

            return(scale);
        }
コード例 #10
0
ファイル: AIAttacker.cs プロジェクト: eto4detak/Kingdom
 public override void StartCommand()
 {
     if (target == null)
     {
         target = UnityExtension.GetClosest(owner, UnitsManager.instance.localities) as Unit;
     }
     owner.Command = new FindEnemyCommand(owner);
 }
コード例 #11
0
 public override void StartCommand()
 {
     if (target == null)
     {
         target = UnityExtension.GetClosest(owner, PController.instance.playerUnits) as CharacterManager;
     }
     owner.Command = new FindEnemyCommand(owner);
 }
コード例 #12
0
ファイル: EditMode2DR.cs プロジェクト: argul/tri_battle
    public void StartEditOperationRules()
    {
        UnityExtension.SetActive(true, editOperation.gameObject);
        UnityExtension.SetActiveBatch(false, editTraits.gameObject, editMatch.gameObject, editCanvas.gameObject);

        operationRuleIndex = 0;
        SyncOperationRuleState();
    }
コード例 #13
0
ファイル: ScreenTouches.cs プロジェクト: ParkDaeyeon/ProjectB
        //public void ResetManualResolution(Vector2 manualArea)
        //{
        //    this.manualResolution = manualArea;
        //    this.UpdateResolution();
        //}
        public void ResetManualResolution()
        {
            var safeArea   = Responsive.GetAreaSizeByMode(AreaMode.Safe);
            var scale      = UnityExtension.GetScaleOfAreaSize(safeArea, Responsive.GetAreaSizeByMode(AreaMode.Viewport));
            var manualArea = safeArea / scale;

            this.manualResolution = manualArea;
        }
コード例 #14
0
 public void SetStartingTarget(List <Unit> units)
 {
     for (int i = 0; i < units.Count; i++)
     {
         Unit enemy = UnityExtension.GetClosest(units[i].transform, UnitsManager.instance.localities)
                      as Unit;
         units[i].Command = new GuardCommand(units[i]);
     }
 }
コード例 #15
0
        public void ShouldCreateAUnityExtension()
        {
            //Act
            var result = new UnityExtension(registrationHelper, options);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(UnityExtension));
        }
コード例 #16
0
        public void ShouldAddMicrosoftPracticesToExcludedAssemblies()
        {
            //Act
            var result = new UnityExtension(registrationHelper, options);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(Bootstrapper.Excluding.Assemblies.Contains("Microsoft.Practices"));
        }
コード例 #17
0
ファイル: App.cs プロジェクト: ParkDaeyeon/ProjectB
 public static void Quit()
 {
     try
     {
         UnityExtension.Quit();
     }
     catch (Exception e)
     {
         Debug.LogWarning(string.Format("APP:QUIT_EXCEPTION:{0}", e));
     }
 }
コード例 #18
0
        public void ShouldReturnANullContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = containerExtension.Container;

            //Assert
            Assert.IsNull(result);
        }
コード例 #19
0
        public void ShouldThrowNoContainerExceptionWhenRegisteringWithTargetTypeBeforeInitializingTheContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = ExceptionAssert.Throws <NoContainerException>(containerExtension.RegisterAll <IBootstrapperContainerExtension>);

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
コード例 #20
0
        public void Register_WhenInvokedWithNonGenericTargetAndContainerIsNotInitialized_ShouldThrowException()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = ExceptionAssert.Throws <NoContainerException>(() => containerExtension.RegisterAll(typeof(IGenericTest <>)));

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
コード例 #21
0
        public void ShouldThrowNoContainerExceptionWhenResolvingMultipleTypesBeforeInitializingTheContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = ExceptionAssert.Throws <NoContainerException>(() => containerExtension.ResolveAll <object>());

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
コード例 #22
0
        public void ShouldThrowNoContainerExceptionWhenSettingServiceLocatorBeforeInitializingTheContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = ExceptionAssert.Throws <NoContainerException>(containerExtension.SetServiceLocator);

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
コード例 #23
0
        public void ShouldResetTheContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            containerExtension.Run();

            //Act
            containerExtension.Reset();

            //Assert
            Assert.IsNull(containerExtension.Container);
        }
コード例 #24
0
        public void ShouldReturnAnIUnityContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            containerExtension.Run();
            var result = containerExtension.Container;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IUnityContainer));
        }
コード例 #25
0
        public void ShouldReturnAUnityOptions()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

            //Act
            var result = containerExtension.Options;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IBootstrapperContainerExtensionOptions));
            Assert.IsInstanceOfType(result, typeof(UnityOptions));
        }
コード例 #26
0
        protected void EditorSetOnClickListener(ButtonCache cache)
        {
            if (null == cache || !cache.Button)
            {
                return;
            }

            var button = cache.Button;

            if (button is Button)
            {
                UnityExtension.SetOnClickObjectPersistantListener((Button)button, this, "OnClick", this.OnClick, cache.GameObject);
            }
        }
コード例 #27
0
        public void ShouldResetTheServiceLocator()
        {
            //Arrange
            ServiceLocator.SetLocatorProvider(A.Fake <IServiceLocator>);
            var containerExtension = new UnityExtension(registrationHelper, options);

            containerExtension.Run();

            //Act
            containerExtension.ResetServiceLocator();

            //Assert
            Assert.IsNull(ServiceLocator.Current);
        }
コード例 #28
0
        public void ShouldInitializeTheContainerToTheValuePassed()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);
            var container          = A.Fake <IUnityContainer>();

            //Act
            containerExtension.InitializeContainer(container);
            var result = containerExtension.Container;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IUnityContainer));
            Assert.AreSame(result, container);
        }
コード例 #29
0
    // Use this for initialization
    void Awake()
    {
        try
        {
            if (experimenterViewOn)
            {
                mainCam            = GameObject.Find("Main Camera").GetComponent <Camera>();
                exptViewCam        = GameObject.Find("CameraExperimenterView").GetComponent <Camera>();
                exptViewCanv       = UnityExtension.GetChildByName(gameObject, "ExperimenterCanvas").GetComponent <Canvas>();
                eyePanelController = GameObject.Find("EyePanel").GetComponent <EyePanelController>();
                // externalDataManager = GameObject.Find("ScriptManager").GetComponent<ExternalDataManager>();

                fixwin = (GameObject)Instantiate(prefabFixwin);
                fixwin.GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.1f);
                fixwin.SetActive(false);

                exptViewRes    = new Vector2(Screen.width, Screen.height);
                mainDisplayRes = new Vector2(Screen.width, Screen.height);

                exptViewCanv.worldCamera = exptViewCam;

                //find the MainCameraCopy and set some values for it
                mainCamObj  = UnityExtension.GetChildByName(gameObject, "MainCameraCopy");
                mainCamCopy = mainCamObj.GetComponent <Camera>();
                mainCamObj.transform.position = Camera.main.transform.position;
                mainCamObj.transform.rotation = Camera.main.transform.rotation;

                playerViewCanv = GameObject.Find("PlayerViewCanvas");
                gazeCircle     = GameObject.Find("GazeCircle");
                gazeParticle   = GameObject.Find("EyeParticle");
                gazeCircle.transform.SetParent(exptViewCanv.transform);
                gazeParticle.transform.SetParent(exptViewCanv.transform);

                fixwin.transform.SetParent(exptViewCanv.transform);

                playerViewCanv.GetComponent <RectTransform>().anchoredPosition = ProportionToPixel(mainCamCopy.rect.position, exptViewRes);
                playerViewRes = new Vector2(mainCamCopy.rect.size.x * exptViewRes.x, mainCamCopy.rect.size.y * exptViewRes.y);
                playerViewCanv.GetComponent <RectTransform>().sizeDelta = playerViewRes;
                playerViewCanv.GetComponent <Image>().enabled           = false;
            }
        }
        catch (Exception e)
        {
            string err = e.Message + "\t" + e.StackTrace;
            //Debug.Log (err);
            throw new System.ArgumentException(err);
        }
    }
コード例 #30
0
        public void ShouldRegisterWithTargetAndImplementationType()
        {
            //Arrange
            var container          = new UnityContainer();
            var containerExtension = new UnityExtension(registrationHelper, options);

            containerExtension.InitializeContainer(container);

            //Act
            containerExtension.Register <IBootstrapperAssemblyProvider, LoadedAssemblyProvider>();
            var result = container.Resolve <IBootstrapperAssemblyProvider>(typeof(LoadedAssemblyProvider).Name);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(LoadedAssemblyProvider));
        }