using Perforce.P4;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Collections;
namespace p4api.net.unit.test
{
///
///This is a test class for StringEnumListTest and is intended
///to contain all StringEnumListTest Unit Tests
///
[TestClass()]
public class StringEnumListTest
{
private TestContext testContextInstance;
///
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//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
enum myEnum { Alpha, beta, GAMMA, DeltaEpsilon };
///
///A test for StringEnumList`1 Constructor
///
[TestMethod()]
public void StringEnumListConstructorTest()
{
IList l = new List();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
StringEnumList actual = new StringEnumList(l);
Assert.AreEqual(4, actual.Count);
}
///
///A test for Add
///
[TestMethod()]
public void AddTest()
{
IList target = new List();
target.Add(myEnum.Alpha);
target.Add(myEnum.beta);
target.Add(myEnum.GAMMA);
target.Add(myEnum.DeltaEpsilon);
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.AreEqual(target.Count, actual.Count);
Assert.AreEqual(target[0], actual[0]);
Assert.AreEqual(target[1], actual[1]);
Assert.AreEqual(target[2], actual[2]);
Assert.AreEqual(target[3], actual[3]);
}
///
///A test for Clear
///
[TestMethod()]
public void ClearTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.AreEqual(4, actual.Count);
actual.Clear();
Assert.AreEqual(0, actual.Count);
}
///
///A test for Contains
///
public void ContainsTestHelper()
{
}
[TestMethod()]
public void ContainsTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.AreEqual(4, actual.Count);
Assert.IsTrue(actual.Contains(myEnum.Alpha));
Assert.IsTrue(actual.Contains(myEnum.beta));
Assert.IsTrue(actual.Contains(myEnum.GAMMA));
Assert.IsTrue(actual.Contains(myEnum.DeltaEpsilon));
}
///
///A test for CopyTo
///
[TestMethod()]
public void CopyToTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.DeltaEpsilon);
actual.Add(myEnum.DeltaEpsilon);
actual.Add(myEnum.DeltaEpsilon);
actual.Add(myEnum.DeltaEpsilon);
myEnum[] l = new myEnum[] {myEnum.Alpha, myEnum.beta, myEnum.GAMMA, myEnum.DeltaEpsilon};
actual.CopyTo(l, 0);
Assert.IsTrue(actual.Contains(myEnum.Alpha));
Assert.IsTrue(actual.Contains(myEnum.beta));
Assert.IsTrue(actual.Contains(myEnum.GAMMA));
Assert.IsTrue(actual.Contains(myEnum.DeltaEpsilon));
}
///
///A test for GetEnumerator
///
[TestMethod()]
public void GetEnumeratorTest()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
IEnumerator actual = l.GetEnumerator();
actual.MoveNext();
Assert.AreEqual(myEnum.Alpha, actual.Current);
}
///
///A test for IndexOf
///
[TestMethod()]
public void IndexOfTest()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
int actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(1, actual);
actual = l.IndexOf(myEnum.DeltaEpsilon);
Assert.AreEqual(-1, actual);
}
///
///A test for Insert
///
[TestMethod()]
public void InsertTest()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
int actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(-1, actual);
l.Insert(1, myEnum.beta);
actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(1, actual);
}
///
///A test for Remove
///
[TestMethod()]
public void RemoveTest()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
int actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(1, actual);
l.Remove(myEnum.beta);
actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(-1, actual);
}
///
///A test for RemoveAt
///
[TestMethod()]
public void RemoveAtTest()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
int actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(1, actual);
l.RemoveAt(actual);
actual = l.IndexOf(myEnum.beta);
Assert.AreEqual(-1, actual);
}
///
///A test for System.Collections.IEnumerable.GetEnumerator
///
[TestMethod()]
public void GetEnumeratorTest1()
{
StringEnumList l = new StringEnumList();
l.Add(myEnum.Alpha);
l.Add(myEnum.beta);
l.Add(myEnum.GAMMA);
l.Add(myEnum.DeltaEpsilon);
IEnumerator actual = l.GetEnumerator();
actual.MoveNext();
Assert.AreEqual(myEnum.Alpha, actual.Current);
}
///
///A test for Count
///
[TestMethod()]
public void CountTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.AreEqual(4, actual.Count);
}
///
///A test for IsReadOnly
///
public void IsReadOnlyTestHelper()
{
}
[TestMethod()]
public void IsReadOnlyTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.IsFalse(actual.IsReadOnly);
}
///
///A test for Item
///
[TestMethod()]
public void ItemTest()
{
StringEnumList actual = new StringEnumList();
actual.Add(myEnum.Alpha);
actual.Add(myEnum.beta);
actual.Add(myEnum.GAMMA);
actual.Add(myEnum.DeltaEpsilon);
Assert.AreEqual(myEnum.beta, actual[1]);
}
}
}