public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mBesansBtn = rc.Get <GameObject>("BesansBtn").GetComponent <Button>(); mJewelBtn = rc.Get <GameObject>("JewelBtn").GetComponent <Button>(); mCommodityItemGo = rc.Get <GameObject>("CommodityItemGo"); mBesansGroupGo = rc.Get <GameObject>("BesansGroupGo"); mJewlGroupGo = rc.Get <GameObject>("JewlGroupGo"); InitPanel(); }
static int _s_set_data(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ReferenceCollector gen_to_be_invoked = (ReferenceCollector)translator.FastGetCSObj(L, 1); gen_to_be_invoked.data = (System.Collections.Generic.List <ReferenceCollectorData>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <ReferenceCollectorData>)); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(0); }
public void Awake() { bundleDownloaderComponent = Game.Scene.GetComponent <BundleDownloaderComponent>(); ReferenceCollector referenceCtrl = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); UpNumText = GetParent <UI>().GameObject.TryGetInChilds <Text>("UpNumText"); updateSlider = GetParent <UI>().GameObject.TryGetInChilds <Slider>("UpdateSlider"); updateSlider.value = 0f; _AppVersionText = referenceCtrl.Get <GameObject>("AppVersionText").Get <Text>(); _ResouceVersionText = referenceCtrl.Get <GameObject>("ResouceVersionText").Get <Text>(); }
static int _g_get_data(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ReferenceCollector gen_to_be_invoked = (ReferenceCollector)translator.FastGetCSObj(L, 1); translator.Push(L, gen_to_be_invoked.data); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(1); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mCloseBtn = rc.Get <GameObject>("CloseBtn").GetComponent <Button>(); mConfirmCreateBtn = rc.Get <GameObject>("ConfirmCreateBtn").GetComponent <Button>(); mSelectWanFaBtn = rc.Get <GameObject>("SelectWanFaBtn").GetComponent <Button>(); mWanFaText = rc.Get <GameObject>("WanFaText").GetComponent <Text>(); mFriendCicleNameInputField = rc.Get <GameObject>("FriendCicleNameInputField").GetComponent <InputField>(); mAnnouncementInputField = rc.Get <GameObject>("AnnouncementInputField").GetComponent <InputField>(); InitPanel(); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mTouristLoginBtn = rc.Get <GameObject>("TouristLoginBtn").GetComponent <Button>(); mWeChatLoginBtn = rc.Get <GameObject>("WeChatLoginBtn").GetComponent <Button>(); mAgreeToggle = rc.Get <GameObject>("AgreeToggle").GetComponent <Toggle>(); mLoginBtn = rc.Get <GameObject>("LoginBtn").GetComponent <Button>(); mAccountInputField = rc.Get <GameObject>("AccountInputField").GetComponent <InputField>(); mTestLoginParentGo = rc.Get <GameObject>("TestLoginParentGo"); InitPanel(); }
public void Awake() { Debug.Log("UIRegisterAndLoginComponent Awake"); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); button = rc.Get <GameObject>("Btn"); button.GetComponent <Button>().onClick.Add(OnButtonClick); backLogin = rc.Get <GameObject>("BackLogin"); backLogin.GetComponent <Button>().onClick.Add(OnClick_BackLogin); account = rc.Get <GameObject>("Account"); pwd = rc.Get <GameObject>("Password"); confirm = rc.Get <GameObject>("Confirm"); }
public void Awake() { ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); usernameInput = rc.Get <GameObject>("usernameInputField").GetComponent <InputField>(); passwordInput = rc.Get <GameObject>("passwordInputField").GetComponent <InputField>(); loginButton = rc.Get <GameObject>("loginButton").GetComponent <Button>(); registerButton = rc.Get <GameObject>("registerButton").GetComponent <Button>(); accountButton = rc.Get <GameObject>("accountButton").GetComponent <Button>(); noticeButton = rc.Get <GameObject>("noticeButton").GetComponent <Button>(); loginButton.onClick.Add(Login); }
public void Awake() { _rf = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); Root = _rf.Get <GameObject>("Root"); QRCode = _rf.Get <GameObject>("QRCode").GetComponent <Image>(); CodeText = _rf.Get <GameObject>("CodeText").Get <Text>(); QRCode.sprite = ETModel.Game.Scene.GetComponent <QRCodeComponent>().GenerateQRImage(GameHelper.GetShareQRCodeURL() + GamePrefs.GetUserId(), 512, 512); CodeText.text = UserDataHelper.UserInfo.PlayerId.ToString(); ButtonHelper.RegisterButtonEvent(_rf, "mask", OnClose); }
public void Awake(object arg) { rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); Text = rc.Get <GameObject>("Text").GetComponent <Text>(); if (arg != null) { message = arg as string; Text.text = message; } }
public override void OnInit(object userData) { base.OnInit(userData); ReferenceCollector collector = RuntimeUIForm.ReferenceCollector; m_QuitButton = collector.GetGO("bt_Quit"); (m_QuitButton.GetComponent(typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnQuitButtonClick); m_QuitButton.SetActive(Application.platform != RuntimePlatform.IPhonePlayer); (collector.Get("bt_About", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnAboutButtonClick); (collector.Get("bt_Setting", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnSettingButtonClick); (collector.Get("bt_Start", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnStartButtonClick); }
public void Awake(PlayerInfo info) { ReferenceCollector rc = GetParent <UI>().rc; Text playerName = rc.GetExt <Text>("PlayerName"); Text playerLevel = rc.GetExt <Text>("PlayerLevel"); Text coinNum = rc.GetExt <Text>("CoinNum"); Text goldNum = rc.GetExt <Text>("GoldNum"); playerName.text = info.playerNickName; playerLevel.text = info.playerLevel.ToString(); coinNum.text = info.coinNum.ToString(); goldNum.text = info.goldNum.ToString(); }
public void Awake() { ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); loginBtn = rc.Get <GameObject>("LoginBtn"); this.registerBtn = rc.Get <GameObject>("RegisterBtn"); loginBtn.GetComponent <Button>().onClick.Add(OnLogin); registerBtn.GetComponent <Button>().onClick.Add(OnRegister); this.account = rc.Get <GameObject>("Account"); this.password = rc.Get <GameObject>("Password"); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mOnlineNumberText = rc.Get <GameObject>("OnlineNumberText").GetComponent <Text>(); mQueryBtn = rc.Get <GameObject>("QueryBtn").GetComponent <Button>(); mUserIdInputField = rc.Get <GameObject>("UserIdInputField").GetComponent <InputField>(); mCloseBtn = rc.Get <GameObject>("CloseBtn").GetComponent <Button>(); mAnewInputPaswordBtn = rc.Get <GameObject>("AnewInputPaswordBtn").GetComponent <Button>(); mServerHeavyBtn = rc.Get <GameObject>("ServerHeavyBtn").GetComponent <Button>(); InitPanel(); }
public void Awake() { rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); buttonCommit = rc.Get <GameObject>("Button_Commit").GetComponent <Button>(); buttonCancel = rc.Get <GameObject>("Button_Cancel").GetComponent <Button>(); textCommit = rc.Get <GameObject>("Text_Commit").GetComponent <Text>(); textCancel = rc.Get <GameObject>("Text_Cancel").GetComponent <Text>(); textContent = rc.Get <GameObject>("Text_Content").GetComponent <Text>(); textTitle = rc.Get <GameObject>("Text_Title").GetComponent <Text>(); UIEventListener.Get(buttonCommit.gameObject).onClick = onClickCommit; UIEventListener.Get(buttonCancel.gameObject).onClick = onClickCancel; }
//---------------------生命周期方法------------------------------- public void Awake() { ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); btnRegister_ = rc.Get <GameObject>("BtnRegister"); btnBack_ = rc.Get <GameObject>("BtnCancle"); inputFieldCount_ = rc.Get <GameObject>("InputFieldCount"); inputFieldPassword_ = rc.Get <GameObject>("InputFieldPassword"); inputFieldPasswordRepeat_ = rc.Get <GameObject>("InputFieldPasswordRepeat"); btnRegister_.GetComponent <Button>().onClick.AddListener(OnRegister); btnBack_.GetComponent <Button>().onClick.AddListener(OnBack); }
public void Awake(string content) { ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); CloseBtn = rc.Get <GameObject>("CloseBtn").GetComponent <Button>(); SureBtn = rc.Get <GameObject>("SureBtn").GetComponent <Button>(); CancelBtn = rc.Get <GameObject>("CancelBtn").GetComponent <Button>(); TipTxt = rc.Get <GameObject>("TipTxt").GetComponent <Text>(); CommonUtil.SetTextFont(this.GetParent <UI>().GameObject); TipTxt.text = content; }
public void Awake() { ReferenceCollector rc = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); UIChatItem = rc.Get <GameObject>("UIChatItem").GetComponent <Button>(); ChatTxt = rc.Get <GameObject>("ChatTxt").GetComponent <Text>(); UIChatItem.GetComponent <Button>().onClick.Add(() => { RequestChat(); }); CommonUtil.SetTextFont(this.GetParent <UI>().GameObject); }
public void VisitAssemblyElementCollectsCorrectReferencesToAttribute() { var assembly = new DelegatingAssembly { OnGetCustomAttributes = i => { Assert.False(i); return new object[] { new FactAttribute() }; } }; var sut = new ReferenceCollector(); var expected = new[] { typeof(FactAttribute).Assembly, typeof(IDisposable).Assembly }; sut.Visit(assembly.ToElement()); Assert.Equal(expected.OrderBy(x => x.ToString()), sut.Value.OrderBy(x => x.ToString())); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mRoomItemGo = rc.Get <GameObject>("RoomItemGo"); mFigureImage = rc.Get <GameObject>("FigureImage").GetComponent <Image>(); mSpeedinessBtn = rc.Get <GameObject>("SpeedinessBtn").GetComponent <Button>(); mGameNameText = rc.Get <GameObject>("GameNameText").GetComponent <Text>(); HandPatent = rc.Get <GameObject>("HandPatent").transform; NewHandPatent = rc.Get <GameObject>("NewHandPatent").transform; InitPanel(); }
public static GameObject CreateSkillTrigger(Skill skill) { GameObject trigger = skill.AddComponent <DGameObjectComponent>().Init("Trigger.unity3d", "Trigger", "SkillTrigger", GlobalComponent.Instance.Trigger); ReferenceCollector rc = trigger.GetComponent <ReferenceCollector>(); rc.Get <GameObject>("TargetAreaTrigger").SetActive(false); rc.Get <GameObject>("CasterAreaTrigger").SetActive(false); rc.Get <GameObject>("CasterFrontTrigger").SetActive(false); trigger.AddComponent <ComponentView>().Component = skill; return(trigger); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mExpressionToggle = rc.Get <GameObject>("ExpressionToggle").GetComponent <Toggle>(); mCharacterToggle = rc.Get <GameObject>("CharacterToggle").GetComponent <Toggle>(); mSendBtn = rc.Get <GameObject>("SendBtn").GetComponent <Button>(); mChatTextInputField = rc.Get <GameObject>("ChatTextInputField").GetComponent <InputField>(); mSpeedinessWordGroupGo = rc.Get <GameObject>("SpeedinessWordGroupGo"); mExpressionGroupGo = rc.Get <GameObject>("ExpressionGroupGo"); mSpeedinessText = rc.Get <GameObject>("SpeedinessText").GetComponent <Text>(); InitPanel(); }
public void Awake() { mCollector = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mLoginBox = mCollector.Get <GameObject>("LoginBox").GetComponent <RectTransform>(); mRegisterBox = mCollector.Get <GameObject>("RegisterBox").GetComponent <RectTransform>(); mToLoginButton = mCollector.Get <GameObject>("ToLoginButton").GetComponent <Button>(); mToRegisterButton = mCollector.Get <GameObject>("ToRegisterButton").GetComponent <Button>(); mLoginButton = mCollector.Get <GameObject>("LoginButton").GetComponent <Button>(); mRegisterButton = mCollector.Get <GameObject>("RegisterButton").GetComponent <Button>(); mLoginUsernameInput = mCollector.Get <GameObject>("LoginUsernameInput").GetComponent <InputField>(); mLoginPasswordInput = mCollector.Get <GameObject>("LoginPasswordInput").GetComponent <InputField>(); mRegisterUsernameInput = mCollector.Get <GameObject>("RegisterUsernameInput").GetComponent <InputField>(); mRegisterPasswordInput = mCollector.Get <GameObject>("RegisterPasswordInput").GetComponent <InputField>(); }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mExitRoomBtn = rc.Get <GameObject>("ExitRoomBtn").GetComponent <Button>(); mWifiImage = rc.Get <GameObject>("WifiImage").GetComponent <Image>(); mTimeText = rc.Get <GameObject>("TimeText").GetComponent <Text>(); mExchangeTableBtn = rc.Get <GameObject>("ExchangeTableBtn").GetComponent <Button>(); mSettingBtn = rc.Get <GameObject>("SettingBtn").GetComponent <Button>(); mRuleBtn = rc.Get <GameObject>("RuleBtn").GetComponent <Button>(); mCollocationBtn = rc.Get <GameObject>("CollocationBtn").GetComponent <Button>(); InitPanel(); }
private static async ETVoid CreatePlayerCube(Vector3 InitPos, ETTaskCompletionSource <PlayerCube> tcs) { try { //创建一个cube角色的3D物体 GameObject resObj = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(Assets.LoadAssetAsync("Assets/Bundles/Prefab/PlayerCube.prefab", typeof(GameObject))); ReferenceCollector rc = resObj.GetComponent <ReferenceCollector>(); GameObject playerCubeObj = GameObject.Instantiate <GameObject>(rc.Get <GameObject>("PlayerCube")); playerCubeObj.transform.position = InitPos; //创建cube角色实体脚本 PlayerCube playerCube = ComponentFactory.Create <PlayerCube, GameObject>(playerCubeObj, false); //创建控制UI UI ui = await UIJoystickFactory.Create(); Game.Scene.GetComponent <UIComponent>().Add(ui); //添加控制组件 PlayerCubeControllerComponent playerCubeControllerComponent = playerCube.AddComponent <PlayerCubeControllerComponent, UI>(ui); //创建准星控制UI UI AttackUI = await UIAttackDirstickFactory.Create(); Game.Scene.GetComponent <UIComponent>().Add(AttackUI); //创建准星3D物品 TargetArrow targetArrow = await TargetArrowFactory.Create(Vector3.zero, playerCube, AttackUI); //管理准星与cube playerCubeControllerComponent.targetArrow = targetArrow; //添加攻击脚本 playerCube.AddComponent <PlayerCubeAttackComponent>(); //添加生命值信息UI playerCube.AddComponent <PlayerCubeHealthComponent>(); //添加攻击伤害同步脚本 playerCube.AddComponent <HurtSyncComponent>(); tcs.SetResult(playerCube); } catch (Exception e) { Log.Error(e); tcs.SetResult(null); } }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); _PengGangGo = rc.Get <GameObject>("PengGangGo"); _LiangBtn = rc.Get <GameObject>("LiangBtn").GetComponent <Button>(); _HuBtn = rc.Get <GameObject>("HuBtn").GetComponent <Button>(); _QiBtn = rc.Get <GameObject>("QiBtn").GetComponent <Button>(); _LiangPaiSelctGo = rc.Get <GameObject>("LiangPaiSelctGo"); _CancelLiangBtn = rc.Get <GameObject>("CancelLiangBtn").GetComponent <Button>(); _PengGangGo.SetActive(false); InitPanel(); }
/// <summary> /// 显示或者隐藏升级按钮 /// </summary> /// <param name="show"></param> public void ShowOrHideUpgradeAndChangePwdBtn(bool show) { ReferenceCollector.Get <GameObject>("UpgradeBtn")?.SetActive(show); ReferenceCollector.Get <GameObject>("ChangePwdBtn")?.SetActive(!show); // if (UpgradeBtn.activeSelf) // { // ChangePwdBtn.transform.localPosition = pwdBtnOldPos; // } // else // { // ChangePwdBtn.transform.localPosition = new Vector3(pwdBtnOldPos.x - 200, pwdBtnOldPos.y, 0); // } }
public override void Awake() { base.Awake(); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); mShoppingBtn = rc.Get <GameObject>("ShoppingBtn").GetComponent <Button>(); mNoticeBtn = rc.Get <GameObject>("NoticeBtn").GetComponent <Button>(); mFriendBtn = rc.Get <GameObject>("FriendBtn").GetComponent <Button>(); mActivityBtn = rc.Get <GameObject>("ActivityBtn").GetComponent <Button>(); mMailBtn = rc.Get <GameObject>("MailBtn").GetComponent <Button>(); mHongBaoBtn = rc.Get <GameObject>("HongBaoBtn").GetComponent <Button>(); mSettingBtn = rc.Get <GameObject>("SettingBtn").GetComponent <Button>(); InitPanel(); }
private Language m_SelectedLanguage = Language.Unspecified; //语言 public override void OnInit(object userData) { base.OnInit(userData); ReferenceCollector collector = RuntimeUIForm.ReferenceCollector; //Music控制 Toggle m_MusicMuteToggle = collector.Get("tog_MusicMute", typeof(Toggle)) as Toggle; m_MusicMuteToggle.isOn = !GameEntry.Sound.IsMuted("Music"); m_MusicMuteToggle.ToggleAddChanged(OnMusicMuteChanged); m_MusicVolumeSlider = collector.Get("slider_MusicVolume", typeof(Slider)) as Slider; m_MusicVolumeSlider.value = GameEntry.Sound.GetGroupVolume("Music"); m_MusicVolumeSlider.SliderAddChanged(OnMusicVolumeChanged); //Sound控制 Toggle m_SoundMuteToggle = collector.Get("tog_SoundMute", typeof(Toggle)) as Toggle; m_SoundMuteToggle.isOn = !GameEntry.Sound.IsMuted("Sound"); m_SoundMuteToggle.ToggleAddChanged(OnSoundMuteChanged); m_SoundVolumeSlider = collector.Get("slider_SoundVolume", typeof(Slider)) as Slider; m_SoundVolumeSlider.value = GameEntry.Sound.GetGroupVolume("Sound"); m_SoundVolumeSlider.SliderAddChanged(OnSoundVolumeChanged); //UISound控制 Toggle m_UISoundMuteToggle = collector.Get("tog_UISoundMute", typeof(Toggle)) as Toggle; m_UISoundMuteToggle.isOn = !GameEntry.Sound.IsMuted("UISound"); m_UISoundMuteToggle.ToggleAddChanged(OnUISoundMuteChanged); m_UISoundVolumeSlider = collector.Get("slider_UISoundVolume", typeof(Slider)) as Slider; m_UISoundVolumeSlider.value = GameEntry.Sound.GetGroupVolume("UISound"); m_UISoundVolumeSlider.SliderAddChanged(OnUISoundVolumeChanged); //提示画布组 m_LanguageTipsCanvasGroup = collector.Get("CanvasGroup_LanguageTips", typeof(CanvasGroup)) as CanvasGroup; //本地化按钮 m_EnglishToggle = collector.Get("tog_English", typeof(Toggle)) as Toggle; m_EnglishToggle.ToggleAddChanged(OnEnglishSelected); m_ChineseSimplifiedToggle = collector.Get("tog_ChineseSimplified", typeof(Toggle)) as Toggle; m_ChineseSimplifiedToggle.ToggleAddChanged(OnChineseSimplifiedSelected); m_ChineseTraditionalToggle = collector.Get("tog_ChineseTraditional", typeof(Toggle)) as Toggle; m_ChineseTraditionalToggle.ToggleAddChanged(OnChineseTraditionalSelected); m_KoreanToggle = collector.Get("tog_Korean", typeof(Toggle)) as Toggle; m_KoreanToggle.ToggleAddChanged(OnKoreanSelected); //按钮 (collector.Get("bt_Confirm", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnConfirmClick); (collector.Get("bt_Cancel", typeof(CommonButton)) as CommonButton).ComButtonAddClick(OnCancelClick); }
public void Awake() { ReferenceCollector rc = this.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>(); enterMap = rc.Get<GameObject>("EnterMap"); this.Account = rc.Get<GameObject>("AccountChild"); this.KillCount = rc.Get<GameObject>("KillCountChild"); this.DeathCount = rc.Get<GameObject>("DeathCountChild"); this.MoneyCount = rc.Get<GameObject>("MoneyCountChild"); GetPlayerInfo().Coroutine(); }
public void Awake() { _rf = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); Text = _rf.Get <GameObject>("Text").GetComponent <Text>(); bg = _rf.Get <GameObject>("bg"); Tween tween = bg.transform.DORotate(new Vector3(0, 0, -360), 2f).SetEase(Ease.Linear).SetLoops(-1); tween.SetRelative(); tween.PlayForward(); }
public void VisitParameterInfoElementCollectsCorrectAssemblies() { var sut = new ReferenceCollector(); var expected = new[] { typeof(ClassImplementingMultiple).Assembly, typeof(IDisposable).Assembly, typeof(ISpecimenContext).Assembly }; var parameterInfoElement = new Methods<ClassForCollectingReference>() .Select(x => x.ParameterizedMethod(null)).GetParameters() .First().ToElement(); var actual = sut.Visit(parameterInfoElement); Assert.Equal(expected.OrderBy(x => x.ToString()), actual.Value.OrderBy(x => x.ToString())); }
private void OnEnable() { referenceCollector = (ReferenceCollector)target; }
public void SutIsReflectionVisitor() { var sut = new ReferenceCollector(); Assert.IsAssignableFrom<IReflectionVisitor<IEnumerable<Assembly>>>(sut); }
public void ValueIsCorrect() { var sut = new ReferenceCollector(); var actual = sut.Value; Assert.Empty(actual); }
public void VisitConstructorInfoElementCollectsCorrectReferencesToAttribute() { var attributes = new object[] { new FactAttribute() }; var constructorInfo = Mock.Of<ConstructorInfo>(x => x.GetCustomAttributes(false) == attributes); var sut = new ReferenceCollector(); var expected = new[] { typeof(FactAttribute).Assembly, typeof(IDisposable).Assembly }; sut.Visit(constructorInfo.ToElement()); Assert.Equal(expected.OrderBy(x => x.ToString()), sut.Value.OrderBy(x => x.ToString())); }
public void VisitTypeElementCollectsCorrectReferencesToAttribute() { var attributes = new object[] { new FactAttribute() }; var type = Mock.Of<Type>(x => x.GetCustomAttributes(false) == attributes && x.Assembly == typeof(object).Assembly); var sut = new ReferenceCollector(); var expected = new[] { typeof(FactAttribute).Assembly, typeof(IDisposable).Assembly }; sut.Visit(type.ToElement()); Assert.Equal(expected.OrderBy(x => x.ToString()), sut.Value.OrderBy(x => x.ToString())); }
public void VisitNonDeclaredFieldInfoElementsFiltersIt() { var fieldInfoElements = typeof(SubClassWithMembers).GetFields(Bindings) .Select(f => f.ToElement()).ToArray(); var sut = new ReferenceCollector(); var actual = sut.Visit(fieldInfoElements); Assert.Empty(actual.Value); }
public void VisitEventInfoElementCollectsCorrectReferencesToAttribute() { var attributes = new object[] { new FactAttribute() }; var eventInfo = Mock.Of<EventInfo>(x => x.GetCustomAttributes(false) == attributes && x.GetAddMethod(true) == Mock.Of<MethodInfo>(m => m.ReturnType == typeof(void)) && x.GetRemoveMethod(true) == Mock.Of<MethodInfo>(m => m.ReturnType == typeof(void))); var sut = new ReferenceCollector(); var expected = new[] { typeof(FactAttribute).Assembly, typeof(IDisposable).Assembly }; sut.Visit(eventInfo.ToElement()); Assert.Equal(expected.OrderBy(x => x.ToString()), sut.Value.OrderBy(x => x.ToString())); }
public void VisitLocalVariableInfoElementCollectsCorrectAssemblies() { var sut = new ReferenceCollector(); var expected = new[] { typeof(ClassImplementingMultiple).Assembly, typeof(IDisposable).Assembly, typeof(ISpecimenContext).Assembly }; var localVariableInfoElement = new Methods<ClassForCollectingReference>() .Select(x => x.ReturnMethod()).GetMethodBody() .LocalVariables.First().ToElement(); var actual = sut.Visit(localVariableInfoElement); Assert.Equal(expected.OrderBy(x => x.ToString()), actual.Value.OrderBy(x => x.ToString())); }
public void VisitDeclaredMethodInfoElementsDoesNotFilterIt() { var methodInfoElements = typeof(ClassWithMembers).GetMethods(Bindings) .Select(x => x.ToElement()).ToArray(); var sut = new ReferenceCollector(); var actual = sut.Visit(methodInfoElements); Assert.NotEmpty(actual.Value); }
public void VisitNullPropertyInfoElementsThrows() { var sut = new ReferenceCollector(); Assert.Throws<ArgumentNullException>(() => sut.Visit((PropertyInfoElement[])null)); }
public void VisitFieldInfoElementCollectsCorrectAssemblies() { var sut = new ReferenceCollector(); var expected = new[] { typeof(ClassImplementingMultiple).Assembly, typeof(IDisposable).Assembly, typeof(ISpecimenContext).Assembly }; var fieldInfoElements = new Fields<ClassForCollectingReference>() .Select(x => x.Field).ToElement(); var actual = sut.Visit(fieldInfoElements); Assert.Equal(expected.OrderBy(x => x.ToString()), actual.Value.OrderBy(x => x.ToString())); }
public void VisitNonDeclaredPropertyInfoElementsFiltersIt() { var propertyInfoElements = typeof(SubClassWithMembers).GetProperties(Bindings) .Select(x => x.ToElement()).ToArray(); var sut = new ReferenceCollector(); var actual = sut.Visit(propertyInfoElements); Assert.Empty(actual.Value); }
public void VisitNullTypeElementThrows() { var sut = new ReferenceCollector(); Assert.Throws<ArgumentNullException>(() => sut.Visit((TypeElement)null)); }
public void VisitNullLocalVariableInfoElementThrows() { var sut = new ReferenceCollector(); Assert.Throws<ArgumentNullException>(() => sut.Visit((LocalVariableInfoElement)null)); }