void LaunchSuccessView() { actualEditor = actualEditor?actualEditor: GetComponentInChildren <TextEditorController>(true); ViewController.main.LevelSucess(levelNumber); SuccessController.main.SetNLines(actualEditor.GetLinesCount()); SuccessController.main.SetTime(timer.GetSeconds()); }
void Start() { patternScreen = GetComponentInChildren <PatternScreen>(true); actualEditor = GetComponentInChildren <TextEditorController>(true); timer = GetComponentInChildren <LevelTimer>(true); patternScreen.gameObject.SetActive(true); patternScreen.FirstLaunch(); patternScreen.goButton.onClick.AddListener(GoButton); // PlayerPrefs.DeleteAll(); }
public void IndexTest() { mockDbContext = CreateMock(); textEditorControlelr = new TextEditorController(mockDbContext); var mockControllerContext = new Mock <ControllerContext>(); SetMockController(); TestAndDebug(); IDbContext CreateMock() { var list = new List <IEntity>() { new TextFilesList { FileId = 1, FileName = "testFileList", UserId = 1, Update = DateTime.Parse("2018/05/01 12:34:56") }, new TextFilesList { FileId = 2, FileName = "testFileList", UserId = 1, Update = DateTime.Parse("2018/05/01 12:37:56") }, new TextFilesList { FileId = 4, FileName = "testFileList", UserId = 2, Update = DateTime.Parse("2019/06/01 12:34:56") } }; var mock = new MockCreator(list); return(mock.GetMockContext().Object); } void TestAndDebug() { string Before1 = ViewEntity.WriteEntityData( mockDbContext.TextFilesList.ToList() ); Debug.WriteLine($"Before List :\r {Before1}"); ViewResult result = textEditorControlelr.Index() as ViewResult; string After1 = ViewEntity.WriteEntityData( (IEnumerable <IEntity>)result.Model ); Debug.WriteLine($"After View :\r {After1}"); } void SetMockController() { textEditorControlelr.ControllerContext = mockControllerContext.Object; textEditorControlelr.ModelState.AddModelError("SessionName", "Required"); } }
public void SetupLevel() { patternScreen = patternScreen?patternScreen: GetComponentInChildren <PatternScreen>(true); timer = timer?timer: GetComponentInChildren <LevelTimer>(true); actualEditor = actualEditor?actualEditor: GetComponentInChildren <TextEditorController>(true); patternScreen.gameObject.SetActive(true); patternScreen.FirstLaunch(); timer.ResetTime(); actualEditor.ResetEditor(); levelStarted = false; }
public virtual void PopupListItemSelected(string searchingKey, string text) { TextPosition end = this.Callback.TextEditorBox.SelectionCaret; TextPosition start = new TextPosition(end.row, end.col - searchingKey.Length); TextEditorController controller = this.Callback.TextEditorBox.Controller; controller.StartTask(); controller.Move(start, false, false); controller.Move(end, false, true); controller.Input(text, false); controller.FinishTask(); }
private bool TrySearchWord(CharPositionInfo[] chars, Direction direction, List <Tuple <Int32Range, string> > words, ref int index) { bool foundBegin = TextEditorController.TrySearchWordBegin(chars, direction, ref index); int indexBegin = index; bool foundEnd = TextEditorController.TrySearchWordEnd(chars, direction, ref index); int indexEnd = index; if (!(foundBegin && foundEnd)) { return(false); } string word = chars.WhereIndex((i, c) => (i >= indexBegin && i < indexEnd)) .ToOneString("", c => c.Content.ToString()); var item = new Tuple <Int32Range, string>(new Int32Range(indexBegin, indexEnd), word); words.Add(item); return(true); }
public void GetViewTest() { mockDbContext = CreateMock(); textEditorControlelr = new TextEditorController(mockDbContext); var mockControllerContext = new Mock <ControllerContext>(); SetMockSession(); SetMockController(); TestAndDebug(); IDbContext CreateMock() { var list = new List <IEntity>() { new EditText { FileId = 1, Text = "aaabbcc" }, new EditText { FileId = 2, Text = "ddeeff" } }; var mock = new MockCreator(list); return(mock.GetMockContext().Object); } void SetMockSession() { HttpSessionStateManager.SetVaue(SessionBaseName.MaxFileId, 1); } void SetMockController() { textEditorControlelr.ControllerContext = mockControllerContext.Object; textEditorControlelr.ModelState.AddModelError("SessionName", "Required"); } void TestAndDebug() { string Before1 = ViewEntity.WriteEntityData( mockDbContext.EditText.ToArray() ); Debug.WriteLine($"Before List :\r {Before1}"); textEditorControlelr.GetView("11223344"); Type type = textEditorControlelr.GetType(); FieldInfo newContext = type.GetField("_context", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance); TextEditorContext context = newContext.GetValue(textEditorControlelr) as TextEditorContext; string After1 = ViewEntity.WriteEntityData( context.EditText.ToArray() ); Debug.WriteLine($"After View :\r {After1}"); } }
public void EditPageTest() { mockDbContext = CreateMock(); textEditorControlelr = new TextEditorController(mockDbContext); var mockControllerContext = new Mock <ControllerContext>(); SetMockSession(); SetMockController(); TestAndDebug(); IDbContext CreateMock() { var fileList = new List <IEntity>() { new EditText { FileId = 1, Text = "testFileList", }, new EditText { FileId = 2, Text = "testFileList2", }, }; var markerList = new List <IEntity>() { new Marker() { MarkerId = 1, Name = "color1", UserId = 1, Color = "#998877", DisplayOrder = 1 }, new Marker() { MarkerId = 1, Name = "color2", UserId = 1, Color = "#998877", DisplayOrder = 2 }, new Marker() { MarkerId = 2, Name = "color3", UserId = 2, Color = "#665544", DisplayOrder = 2 }, }; var mock = new MockCreator(fileList); mock.SetMock(markerList); return(mock.GetMockContext().Object); } void TestAndDebug() { string Before1 = ViewEntity.WriteEntityData( mockDbContext.Marker.ToArray() ); Debug.WriteLine($"Before List :\r {Before1}"); int UserId = 1; ViewResult result = textEditorControlelr.EditPage(UserId) as ViewResult; EditPageDto editPageDto = (EditPageDto)result.Model; string After1 = ViewEntity.WriteEntityData( editPageDto.MarkerList ); Debug.WriteLine($"After View :\r {After1}"); } void SetMockSession() { mockControllerContext.Setup(x => x.HttpContext.Session["UserId"]).Returns("1"); } void SetMockController() { textEditorControlelr.ControllerContext = mockControllerContext.Object; textEditorControlelr.ModelState.AddModelError("SessionName", "Required"); } }
public TextEditorControllerTests() { this.textEditorController = new TextEditorController(changeLog, sr, sw, textEditor); }
public void TestTextsInteractive() { string text = "První slovo, třetí slovo (páté slovo v závorce)."; // 012345678901234567890123456789012345678901234567890 // 0 1 2 3 4 5 // Text je dlouhý 48 znaků, 1 znak má šířku 5px, jeden řádek má max 160px, budou dva řádky: "První slovo, třetí slovo (páté s", "lovo v závorce).": var chars = CharPositionInfo.CreateTestChars(text, new SizeF(5, 8), 160f); bool found; int idx = 28; // "t" ve slově "páté" found = TextEditorController.TrySearchWordEnd(chars, Direction.Positive, ref idx); // Má být 30 if (idx != 30) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordEnd(a): Nalezený index je chybný: {idx}, má být: 30."); } found = TextEditorController.TrySearchWordEnd(chars, Direction.Positive, ref idx); // Má zůstat 30 if (idx != 30) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordEnd(b): Nalezený index je chybný: {idx}, má být: 30."); } idx++; found = TextEditorController.TrySearchWordEnd(chars, Direction.Positive, ref idx); // Má se najít konec dalšího slova = 36 if (idx != 36) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordEnd(c): Nalezený index je chybný: {idx}, má být: 30."); } idx = 30; found = TextEditorController.TrySearchWordBegin(chars, Direction.Negative, ref idx); // Má se najít 26 if (idx != 26) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordBegin(d): Nalezený index je chybný: {idx}, má být: 26."); } found = TextEditorController.TrySearchWordBegin(chars, Direction.Negative, ref idx); // Má zůstat 26 if (idx != 26) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordBegin(e): Nalezený index je chybný: {idx}, má být: 26."); } found = TextEditorController.TrySearchWordEnd(chars, Direction.Negative, ref idx); // Má se najít 24 if (idx != 24) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordEnd(f): Nalezený index je chybný: {idx}, má být: 24."); } found = TextEditorController.TrySearchWordBegin(chars, Direction.Negative, ref idx); // Má se najít 19 if (idx != 19) { throw new AssertFailedException($"Chyba GTextEdit.EditorStateInfo.TrySearchWordBegin(g): Nalezený index je chybný: {idx}, má být: 19."); } Int32Range word; found = TextEditorController.TrySearchNearWord(chars, 14, out word); // Má se najít slovo "třetí" = 13-18 _CheckWord(found, word, "A", 13, 18); found = TextEditorController.TrySearchNearWord(chars, 25, out word); // Má se najít závorka před "(páté", najde se "páté" = 26-30 _CheckWord(found, word, "B", 26, 30); found = TextEditorController.TrySearchNearWord(chars, 30, out word, false); // Má se najít mezera mezi "páté slovo", false = najde "páté" = 26-30 _CheckWord(found, word, "C", 26, 30); found = TextEditorController.TrySearchNearWord(chars, 30, out word, true); // Má se najít mezera mezi "páté slovo", true = najde "slovo" = 31-36 _CheckWord(found, word, "D", 31, 36); }
public void SetController(TextEditorController controller) { this.controller = (ModEditorController)controller; }