using Perforce.P4;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
namespace p4api.net.unit.test
{
///
///This is a test class for FormSpecTest and is intended
///to contain all FormSpecTest Unit Tests
///
[TestClass()]
public class FormSpecTest
{
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
///
///A test for Comments
///
[TestMethod()]
public void CommentsTest()
{
List fields = null; // TODO: Initialize to an appropriate value
Dictionary fieldmap=null;
List words = null; // TODO: Initialize to an appropriate value
List formats = null; // TODO: Initialize to an appropriate value
Dictionary values = null; // TODO: Initialize to an appropriate value
Dictionary presets = null; // TODO: Initialize to an appropriate value
string comments = "here is a comment";
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
string expected = comments;
string actual;
target.Comments = expected;
actual = target.Comments;
Assert.AreEqual(expected, actual);
}
///
///A test for Fields
///
[TestMethod()]
public void FieldsTest()
{
List fields = new List();
Dictionary fieldmap = null;
SpecField Field1 = new SpecField(116, "field1", SpecFieldDataType.Date, 10, SpecFieldFieldType.Key);
SpecField Field2 = new SpecField(118, "field2", SpecFieldDataType.Word, 64, SpecFieldFieldType.Optional);
List words = null; // TODO: Initialize to an appropriate value
List formats = null; // TODO: Initialize to an appropriate value
Dictionary values = null; // TODO: Initialize to an appropriate value
Dictionary presets = null; // TODO: Initialize to an appropriate value
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
List expected = fields;
target.Fields.Add(Field1);
target.Fields.Add(Field2);
Assert.AreEqual(Field1, target.Fields[0]);
Assert.AreEqual(Field2, target.Fields[1]);
}
///
///A test for Formats
///
[TestMethod()]
public void FormatsTest()
{
List fields = null; // TODO: Initialize to an appropriate value
Dictionary fieldmap = null;
List words = null; // TODO: Initialize to an appropriate value
List formats = new List();
string Format1 = "Change 1 L";
string Format2 = "Date 3 R";
Dictionary values = null; // TODO: Initialize to an appropriate value
Dictionary presets = null; // TODO: Initialize to an appropriate value
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
List expected = formats;
target.Formats.Add(Format1);
target.Formats.Add(Format2);
Assert.AreEqual(Format1, target.Formats[0]);
Assert.AreEqual(Format2, target.Formats[1]);
}
///
///A test for Presets
///
[TestMethod()]
public void PresetsTest()
{
List fields = null; // TODO: Initialize to an appropriate value
Dictionary fieldmap = null;
List words = null; // TODO: Initialize to an appropriate value
List formats = null; // TODO: Initialize to an appropriate value
Dictionary values = null; // TODO: Initialize to an appropriate value
Dictionary presets = new Dictionary();
presets.Add("Status", "open");
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
Dictionary expected = presets; // TODO: Initialize to an appropriate value
Dictionary actual;
target.Presets = expected;
actual = target.Presets;
Assert.AreEqual(expected, actual);
}
///
///A test for Values
///
[TestMethod()]
public void ValuesTest()
{
List fields = null; // TODO: Initialize to an appropriate value
Dictionary fieldmap = null;
List words = null; // TODO: Initialize to an appropriate value
List formats = null; // TODO: Initialize to an appropriate value
Dictionary values = new Dictionary();
values.Add("Severity", "A/B/C");
Dictionary presets = null; // TODO: Initialize to an appropriate value
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
Dictionary expected = values; // TODO: Initialize to an appropriate value
Dictionary actual;
target.Values = expected;
actual = target.Values;
Assert.AreEqual(expected, actual);
}
///
///A test for Words
///
[TestMethod()]
public void WordsTest()
{
List fields = null; // TODO: Initialize to an appropriate value
Dictionary fieldmap = null;
List words = new List();
string Word1 = "View 2";
string Word2 = "View 4";
List formats = null; // TODO: Initialize to an appropriate value
Dictionary values = null; // TODO: Initialize to an appropriate value
Dictionary presets = null; // TODO: Initialize to an appropriate value
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, comments); // TODO: Initialize to an appropriate value
target.Words.Add(Word1);
target.Words.Add(Word2);
Assert.AreEqual(Word1, target.Words[0]);
Assert.AreEqual(Word2, target.Words[1]);
}
}
}