using Perforce.P4;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using NLog;
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 static Logger logger = LogManager.GetCurrentClassLogger();
public TestContext TestContext { get; set; }
[TestInitialize]
public void SetupTest()
{
Utilities.LogTestStart(TestContext);
}
[TestCleanup]
public void CleanupTest()
{
Utilities.LogTestFinish(TestContext);
}
#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
List openable = null;
List maxwords = null;
string comments = "here is a comment";
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, openable, maxwords, 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
List openable = null;
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, openable, maxwords, 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
List openable = null;
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, openable, maxwords, 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");
List openable = null;
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap,words, formats, values, presets, openable, maxwords, 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
List openable = null;
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, openable, maxwords, 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
List openable = null;
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, openable, maxwords, 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]);
}
///
///A test for Openable
///
[TestMethod()]
public void OpenableTest()
{
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
List openable = new List();
string openable1 = "yes";
List maxwords = null;
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, openable, maxwords, comments); // TODO: Initialize to an appropriate value
target.Openable.Add(openable1);
Assert.AreEqual(openable1, target.Openable[0]);
}
///
///A test for Maxwords
///
[TestMethod()]
public void MaxwordsTest()
{
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
List openable = null;
List maxwords = new List();
string maxwords1 = "100";
string comments = string.Empty; // TODO: Initialize to an appropriate value
FormSpec target = new FormSpec(fields, fieldmap, words, formats, values, presets, openable, maxwords, comments); // TODO: Initialize to an appropriate value
target.Maxwords.Add(maxwords1);
Assert.AreEqual(maxwords1, target.Maxwords[0]);
}
}
}