-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fix to update text on navigation using up/down arrow (#4626)
* Added fix to update text on navigation using up/down arrow * Fix incorrect alignment with ghost text * Added tests
- Loading branch information
1 parent
1360359
commit 79eda16
Showing
3 changed files
with
272 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Wox.Plugin; | ||
using Wox.ViewModel; | ||
|
||
namespace Wox.Test | ||
{ | ||
[TestFixture] | ||
class MainViewModelTest | ||
{ | ||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenInputIsNull() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = null; | ||
String query = "M"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenInputIsEmpty() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = string.Empty; | ||
String query = "M"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenQueryIsNull() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "M"; | ||
String query = null; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenQueryIsEmpty() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "M"; | ||
String query = string.Empty; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenIndexIsNonZero() | ||
{ | ||
// Arrange | ||
int index = 2; | ||
string input = "Visual"; | ||
String query = "Vis"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsMatchingString_WhenIndexIsZeroAndMatch() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "VISUAL"; | ||
String query = "VIs"; | ||
string ExpectedAutoCompleteText = "VIsUAL"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetAutoCompleteTextReturnsEmptyString_WhenIndexIsZeroAndNoMatch() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "VISUAL"; | ||
String query = "Vim"; | ||
string ExpectedAutoCompleteText = string.Empty; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsEmptyString_WhenInputIsNull() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = null; | ||
String query = "M"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsEmptyString_WhenInputIsEmpty() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = string.Empty; | ||
String query = "M"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, string.Empty); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsInputString_WhenQueryIsNull() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "Visual"; | ||
String query = null; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, input); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsInputString_WhenQueryIsEmpty() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "Visual"; | ||
String query = string.Empty; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, input); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsMatchingStringWithCase_WhenIndexIsZeroAndMatch() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "VISUAL"; | ||
String query = "VIs"; | ||
string ExpectedAutoCompleteText = "VIsUAL"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, ExpectedAutoCompleteText); | ||
} | ||
|
||
[Test] | ||
public void MainViewModel_GetSearchTextReturnsInput_WhenIndexIsZeroAndNoMatch() | ||
{ | ||
// Arrange | ||
int index = 0; | ||
string input = "VISUAL"; | ||
String query = "Vim"; | ||
|
||
// Act | ||
string autoCompleteText = MainViewModel.GetSearchText(index, input, query); | ||
|
||
// Assert | ||
Assert.AreEqual(autoCompleteText, input); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters