/// <summary> /// 渐隐 /// </summary> private void FadeWin() { var fade = TweenAlpha.Begin(_itemBg.gameObject, 1f, 0f); fade.delay = 1f; fade.SetOnFinished(() => TipsController.GoBack()); }
public void SetUp() { ServiceLocatorInitializer.Init(); controller = new TipsController( CreateMockTipRepository(), TasksControllerTests.CreateMockTaskRepository(), MockRepository.GenerateMock <IUserRepository>()); }
private void Awake() { FindObject(transform); _controller = (TipsController)UIManager.GetControler(UIName.TIPS); UIEventListener.Get(_btnClose).onClick = TipsController.GoBack; _controller.RegisterUIEvent(UIEventID.TIPS, OnEventSetContent); _camObj = GameSceneManager.uiCameraObj.GetComponent <Camera>(); }
// Constructor with common setup for all tests public TipsTests() { repo = new FakeTipsRepository(); controller = new TipsController(repo); member = new AppUser { FullName = JOE_USER }; tip = new Tip { TipText = "Just testing", Member = member }; }
public void Get() { TipsController tipsController = new TipsController(tipService); IEnumerable <Tip> result = tipsController.Get(); // Assert Assert.IsNotNull(result); Assert.AreEqual(4, result.Count()); Assert.AreEqual(new Tip() { Id = new Guid("8fda5124-65b2-43e3-9414-34d18f62e17e"), Title = "title1", Content = "is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum", ImageUrl = "https://cdn.pocket-lint.com/r/s/1200x/assets/images/120309-phones-buyer-s-guide-best-smartphones-image1-cnxvifjlms.jpg" }, result.ElementAt(0)); }
/* * /// <summary> * /// 带图标 * /// </summary> * /// <param name="dic"></param> * /// <param name="labels"></param> * private void SetContentWithIcon(ref Dictionary<string, object> dic, ref List<KeyValuePair<string, object>> labels) * { * int type = -1; * int lev = 0; * if (dic.ContainsKey("Type")) * { * type = (int)dic["Type"]; * } * if (dic.ContainsKey("Level")) * { * lev = (int)dic["Level"]; * } * var icon = _itemIcon; * var iconBg = _itemIconBg; * var title = _name; * var hasIconBg = dic.ContainsKey("IconBg"); * var offsetIconBg = hasIconBg ? 27 : 10; * var offsetText = hasIconBg ? 37 : 20; * UtilTools.SetIcon(icon, dic["Icon"].ToString(), type, lev); * var itemIcon = icon.GetComponent<UISprite>(); * itemIcon.MakePixelPerfect(); * itemIcon.topAnchor.absolute = -offsetIconBg; * itemIcon.bottomAnchor.absolute = -itemIcon.height - offsetIconBg; * itemIcon.leftAnchor.absolute = offsetIconBg; * itemIcon.rightAnchor.absolute = itemIcon.width + offsetIconBg; * * var imgWidth = itemIcon.width + 40; * if (hasIconBg) { * iconBg.spriteName = iconBg.ToString(); * iconBg.SetAnchor(icon.gameObject, -17, -17, 17, 17); * iconBg.gameObject.SetActive(true); * imgWidth = iconBg.width + 40; * } else { * iconBg.gameObject.SetActive(false); * } * * title.text = dic["Title"].ToString(); * title.topAnchor.target = _itemBg; * title.topAnchor.relative = 1f; * title.topAnchor.absolute = -20; * * title.bottomAnchor.target = _itemBg; * title.bottomAnchor.relative = 1f; * title.bottomAnchor.absolute = -42; * * title.leftAnchor.target = icon; * title.leftAnchor.relative = 1f; * title.leftAnchor.absolute = offsetText; * * title.rightAnchor.target = icon; * title.rightAnchor.relative = 1f; * title.rightAnchor.absolute = 200; * * _titleUnderLine.GetComponent<UISprite>().width = title.width + 15; * _des.width = 535 - imgWidth; * _des.text = dic["Des"].ToString(); * var iconHeight = hasIconBg ? itemIcon.height + 54 : itemIcon.height + 20; * var textHeight = 78 + labels.Count * 30 + _des.height; * _itemBg.GetComponent<UISprite>().height = Math.Max(iconHeight, textHeight); * } * /// <summary> * /// 在当前帧结束时设置窗口内容 * /// </summary> * /// <param name="labels"></param> * /// <param name="hasIcon"></param> * /// <returns></returns> * private IEnumerator SetContentAtEndOfFrame(List<KeyValuePair<string, object>> labels, bool hasIcon) * { * yield return new WaitForEndOfFrame(); * var pos = hasIcon * ? _name.transform.localPosition + new Vector3(-15, -22, 0) * : _name.transform.localPosition + 22 * Vector3.down; * _des.transform.localPosition = pos; * for (int i = 0; i < labels.Count; i++) { * var label = labels[i]; * var obj = NGUITools.AddChild(_labesObj, _labelCell); * obj.transform.localPosition += Vector3.down * 30 * i; * var addLabel = obj.GetComponent<UILabel>(); * addLabel.text = label.Value.ToString(); * * var line = obj.transform.Find("Line").gameObject; * if (label.Key[1] == 'U') { * line.SetActive(true); * line.GetComponent<UISprite>().width = addLabel.width + 10; * } else { * line.SetActive(false); * } * switch (label.Key[2]) { * case 'L': * obj.GetComponent<UILabel>().alignment = NGUIText.Alignment.Left; * break; * case 'R': * obj.GetComponent<UILabel>().alignment = NGUIText.Alignment.Right; * break; * default: * obj.GetComponent<UILabel>().alignment = NGUIText.Alignment.Center; * break; * } * } * } * */ /// <summary> /// 设置位置 /// </summary> /// <param name="trans"></param> private void GetPos(Transform trans) { var itemBg = _itemBg; if (trans == null) { TipsController.GoBack(); } UIWidget wid = trans.GetComponent <UIWidget>(); if (wid == null) { TipsController.GoBack(); } var parentCorners = wid.worldCorners; var tipBoxCorners = itemBg.GetComponent <UIWidget>().worldCorners; var viewPoint = new Vector3[4]; for (var i = 0; i < 3; i++) { viewPoint[i] = _camObj.WorldToViewportPoint(parentCorners[i]); parentCorners[i].z = tipBoxCorners[i].z; } var x1 = viewPoint[0].x; var y1 = viewPoint[0].y; var x2 = viewPoint[3].x; var y2 = viewPoint[2].y; if (x1 < 0.5 && y1 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomLeft; itemBg.position = parentCorners[2]; } else if (x1 < 0.5 && y1 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopLeft; itemBg.position = parentCorners[0]; } else if (x1 > 0.5 && y1 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomRight; itemBg.position = parentCorners[0]; } else if (x1 > 0.5 && y1 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopRight; itemBg.position = parentCorners[1]; } else if (x1 < 0.5 && y2 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomLeft; itemBg.position = parentCorners[1]; } else if (x1 < 0.5 && y2 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopLeft; itemBg.position = parentCorners[0]; } else if (x1 > 0.5 && y2 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomRight; itemBg.position = parentCorners[0]; } else if (x1 > 0.5 && y2 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopRight; itemBg.position = parentCorners[1]; } else if (x2 < 0.5 && y1 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomLeft; itemBg.position = parentCorners[3]; } else if (x2 < 0.5 && y1 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopLeft; itemBg.position = parentCorners[2]; } else if (x2 > 0.5 && y1 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomRight; itemBg.position = parentCorners[0]; } else if (x2 > 0.5 && y1 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopRight; itemBg.position = parentCorners[1]; } else if (x2 < 0.5 && y2 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomLeft; itemBg.position = parentCorners[3]; } else if (x2 < 0.5 && y2 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopLeft; itemBg.position = parentCorners[2]; } else if (x2 > 0.5 && y2 < 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.BottomRight; itemBg.position = parentCorners[0]; } else if (x2 > 0.5 && y2 > 0.5) { itemBg.GetComponent <UIWidget>().rawPivot = UIWidget.Pivot.TopRight; itemBg.position = parentCorners[1]; } }
public void SetUp() { _mediator = Substitute.For <IMediator>(); _sut = new TipsController(_mediator); }