|
using RoslynCodeSearcher;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using FastColoredTextBoxNS;
using KRBTabControl;
using System.Collections.Generic;
namespace RoslynCodesearcher.Unittest
{
/// <summary>
///This is a test class for TabControllerTest and is intended
///to contain all TabControllerTest Unit Tests
///</summary>
[TestClass()]
public class TabControllerTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
// Use ClassInitialize to run code before running the first test in the class
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
TabController.TabControl = null;
TabController_Accessor._fastColoredTextBoxes = new List<FastColoredTextBox>();
}
//Use ClassCleanup to run code after all tests in a class have run
[ClassCleanup()]
public static void MyClassCleanup()
{
TabController.TabControl = null;
TabController_Accessor._fastColoredTextBoxes = new List<FastColoredTextBox>();
}
//
//You can use the following additional attributes as you write your tests:
//
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for RemoveTab
///</summary>
[TestMethod()]
public void RemoveTabTest()
{
//Clean up
TabController_Accessor._fastColoredTextBoxes = new List<FastColoredTextBox>();
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 0);
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 1);
int index = 0;
TabController.RemoveTab(index);
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 0);
}
/// <summary>
///A test for InitImages
///</summary>
[TestMethod()]
public void InitImagesTest()
{
KRBTabControl.KRBTabControl tabControl = new KRBTabControl.KRBTabControl();
TabController.TabControl = tabControl;
TabController.TabControl.ImageList = new System.Windows.Forms.ImageList();
Assert.IsTrue(TabController.TabControl.ImageList.Images.Count == 0);
TabController.InitImages();
Assert.IsTrue(TabController.TabControl.ImageList.Images.Count > 0);
}
/// <summary>
///A test for InitFirstTab
///</summary>
[TestMethod()]
public void InitFirstTabTest()
{
TabController_Accessor._fastColoredTextBoxes = new List<FastColoredTextBox>();
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 0);
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabController.InitFirstTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
//AddTab and InitFirstTab both add a FastColoredTextBox to the tab
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 2);
}
/// <summary>
///A test for GetTabByGuid
///</summary>
[TestMethod()]
public void GetTabByGuidTest()
{
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
Guid expected = guid;
TabPageEx actual = TabController.GetTabByGuid(guid);
Assert.AreEqual(expected, actual.Guid);
}
/// <summary>
///A test for GetFastColoredTextBoxByGuid
///</summary>
[TestMethod()]
public void GetFastColoredTextBoxByGuidTest()
{
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
Guid expected = guid;
FastColoredTextBox actual = TabController.GetFastColoredTextBoxByGuid(guid);
Assert.AreEqual(expected, actual.Guid);
}
/// <summary>
///A test for AddTab
///</summary>
[TestMethod()]
public void AddTabTest()
{
TabController_Accessor._fastColoredTextBoxes = new List<FastColoredTextBox>();
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 0);
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
Assert.IsTrue(TabController_Accessor._fastColoredTextBoxes.Count == 1);
}
/// <summary>
///A test for AddFastColoredTextBoxToTabPage
///</summary>
[TestMethod()]
public void AddFastColoredTextBoxToTabPageTest()
{
TabPageEx tabPage = new TabPageEx();
FastColoredTextBox fastColoredTextBox = new FastColoredTextBox();
Assert.IsTrue(tabPage.Controls.Count == 0);
TabController.AddFastColoredTextBoxToTabPage(tabPage, fastColoredTextBox);
Assert.IsTrue(tabPage.Controls.Count == 1);
}
/// <summary>
///A test for UpdateSearchTextOnTab
///</summary>
[TestMethod()]
public void UpdateSearchTextOnTabTest()
{
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
string text = "textontab";
TabController.UpdateSearchTextOnTab(text);
Assert.AreEqual(text, tabPage.Text);
}
/// <summary>
///A test for WriteResults
///</summary>
[TestMethod()]
public void WriteResultsTest()
{
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
RoslynCodeSearcher.Language language = new RoslynCodeSearcher.Language();
string text = "WriteResults test";
TabController.WriteResults(guid, language, text);
FastColoredTextBox findTextbox = TabController.GetFastColoredTextBoxByGuid(guid);
Assert.IsTrue(findTextbox.Text.Contains(text), "textbox should contain text");
}
/// <summary>
///A test for FastColoredTextBoxes
///</summary>
[TestMethod()]
public void FastColoredTextBoxesTest()
{
TabController.FastColoredTextBoxes = new List<FastColoredTextBox>();
Assert.IsTrue(TabController.FastColoredTextBoxes.Count == 0);
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Guid guid = tabPage.Guid;
Assert.IsTrue(TabController.FastColoredTextBoxes.Count == 1);
}
/// <summary>
///A test for SelectedTab
///</summary>
[TestMethod()]
public void SelectedTabTest()
{
TabController.TabControl = new KRBTabControl.KRBTabControl();
TabController.AddTab();
TabPageEx tabPage = (TabPageEx)TabController.SelectedTab;
Assert.IsNotNull(tabPage);
}
/// <summary>
///A test for TabControl
///</summary>
[TestMethod()]
public void TabControlTest()
{
KRBTabControl.KRBTabControl tabControl = new KRBTabControl.KRBTabControl();
TabController.TabControl = tabControl;
Assert.IsNotNull(TabController.TabControl);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.