using Perforce.P4;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace p4api.net.unit.test
{
///
///This is a test class for LabelTest and is intended
///to contain all LabelTest Unit Tests
///
[TestClass()]
public class LabelTest
{
private TestContext testContextInstance;
static string id = "newLabel";
static string owner = "admin";
static DateTime updated = new DateTime(2011, 03, 21);
static DateTime accessed = new DateTime(2011, 03, 21);
static string description = "created by admin";
static bool locked = true;
static ViewMap viewmap = new ViewMap();
static MapEntry m = new MapEntry(MapType.Include, new DepotPath("//depot/main/... "), null);
static MapEntry m1 = new MapEntry(MapType.Include, new DepotPath("//depot/rel1/... "), null);
static MapEntry m2 = new MapEntry(MapType.Include, new DepotPath("//depot/dev/... "), null);
static FormSpec spec = null;
static string options = "locked";
static string revision = null;
static Label target = null;
static void setTarget()
{
viewmap.Add(m);
viewmap.Add(m1);
viewmap.Add(m2);
target = new Label(
id, owner, updated, accessed, description, locked, revision, viewmap, spec, options);
}
///
///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
///
///A test for Access
///
[TestMethod()]
public void AccessTest()
{
DateTime expected = new DateTime(2011, 02, 17);
setTarget();
Assert.AreEqual(target.Access, new DateTime(2011, 03, 21));
target.Access = expected;
DateTime actual = target.Access;
Assert.AreEqual(expected, actual);
}
///
///A test for Description
///
[TestMethod()]
public void DescriptionTest()
{
string expected = "description";
setTarget();
Assert.AreEqual(target.Description, "created by admin");
target.Description = expected;
string actual = target.Description;
Assert.AreEqual(expected, actual);
}
///
///A test for Id
///
[TestMethod()]
public void IdTest()
{
string expected = "labelname";
setTarget();
Assert.AreEqual(target.Id, "newLabel");
target.Id = expected;
string actual = target.Id;
Assert.AreEqual(expected, actual);
}
///
///A test for Locked
///
[TestMethod()]
public void LockedTest()
{
bool expected = false;
setTarget();
Assert.AreEqual(target.Locked, true);
target.Locked = expected;
bool actual = target.Locked;
Assert.AreEqual(expected, actual);
}
///
///A test for Options
///
[TestMethod()]
public void OptionsTest()
{
string expected = "unlocked";
setTarget();
Assert.AreEqual(target.Options, "locked");
target.Locked = true;
bool actual = target.Locked;
Assert.AreEqual(true, actual);
}
///
///A test for Owner
///
[TestMethod()]
public void OwnerTest()
{
string expected = "perforce";
setTarget();
Assert.AreEqual(target.Owner, "admin");
target.Owner = expected;
string actual = target.Owner;
Assert.AreEqual(expected, actual);
}
///
///A test for Updated
///
[TestMethod()]
public void UpdatedTest()
{
DateTime expected = new DateTime(2011, 02, 17);
setTarget();
Assert.AreEqual(target.Update, new DateTime(2011, 03, 21));
target.Update = expected;
DateTime actual = target.Update;
Assert.AreEqual(expected, actual);
}
///
///A test for ViewMap
///
[TestMethod()]
public void ViewMapTest()
{
ViewMap expected = new ViewMap();
MapEntry m = new MapEntry(MapType.Include, new DepotPath("//depot/main/... "), null);
expected.Add(m);
setTarget();
Assert.AreEqual(target.ViewMap[1].Left.Path, "//depot/rel1/...");
target.ViewMap = expected;
ViewMap actual = target.ViewMap;
Assert.AreEqual(expected, actual);
}
}
}