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)); }
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); }
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); }
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)); }
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>()); }
public void StartEditCanvas() { UnityExtension.SetActive(true, editCanvas.gameObject); UnityExtension.SetActiveBatch(false, editTraits.gameObject, editMatch.gameObject, editOperation.gameObject); ResetCanvas(); }
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; }
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); } } } }
public float GetContentScale() { var areaSize = Responsive.GetAreaSizeByMode(AreaMode.Safe); var baseSize = Responsive.GetAreaSizeByMode(AreaMode.Viewport); var scale = UnityExtension.GetScaleOfAreaSize(areaSize, baseSize); return(scale); }
public override void StartCommand() { if (target == null) { target = UnityExtension.GetClosest(owner, UnitsManager.instance.localities) as Unit; } owner.Command = new FindEnemyCommand(owner); }
public override void StartCommand() { if (target == null) { target = UnityExtension.GetClosest(owner, PController.instance.playerUnits) as CharacterManager; } owner.Command = new FindEnemyCommand(owner); }
public void StartEditOperationRules() { UnityExtension.SetActive(true, editOperation.gameObject); UnityExtension.SetActiveBatch(false, editTraits.gameObject, editMatch.gameObject, editCanvas.gameObject); operationRuleIndex = 0; SyncOperationRuleState(); }
//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; }
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]); } }
public void ShouldCreateAUnityExtension() { //Act var result = new UnityExtension(registrationHelper, options); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(UnityExtension)); }
public void ShouldAddMicrosoftPracticesToExcludedAssemblies() { //Act var result = new UnityExtension(registrationHelper, options); //Assert Assert.IsNotNull(result); Assert.IsTrue(Bootstrapper.Excluding.Assemblies.Contains("Microsoft.Practices")); }
public static void Quit() { try { UnityExtension.Quit(); } catch (Exception e) { Debug.LogWarning(string.Format("APP:QUIT_EXCEPTION:{0}", e)); } }
public void ShouldReturnANullContainer() { //Arrange var containerExtension = new UnityExtension(registrationHelper, options); //Act var result = containerExtension.Container; //Assert Assert.IsNull(result); }
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); }
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); }
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); }
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); }
public void ShouldResetTheContainer() { //Arrange var containerExtension = new UnityExtension(registrationHelper, options); containerExtension.Run(); //Act containerExtension.Reset(); //Assert Assert.IsNull(containerExtension.Container); }
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)); }
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)); }
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); } }
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); }
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); }
// 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); } }
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)); }