本文整理匯總了C#中NUnit.Framework.List.AsReadOnly方法的典型用法代碼示例。如果您正苦於以下問題:C# List.AsReadOnly方法的具體用法?C# List.AsReadOnly怎麽用?C# List.AsReadOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NUnit.Framework.List
的用法示例。
在下文中一共展示了List.AsReadOnly方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AgentClientTest
static AgentClientTest()
{
rsa1Key = KeyGenerator.CreateKey(SshVersion.SSH1,
PublicKeyAlgorithm.SSH_RSA, "SSH1 RSA test key");
rsaKey = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.SSH_RSA, "SSH2 RSA test key");
dsaKey = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.SSH_DSS, "SSH2 DSA test key");
ecdsa256Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP256, "SSH2 ECDSA 256 test key");
ecdsa384Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP384, "SSH2 ECDSA 384 test key");
ecdsa521Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP521, "SSH2 ECDSA 521 test key");
ed25519Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ED25519, "SSH2 Ed25519 test key");
List<SshKey> keyList = new List<SshKey>();
keyList.Add(rsa1Key);
keyList.Add(rsaKey);
keyList.Add(dsaKey);
keyList.Add(ecdsa256Key);
keyList.Add(ecdsa384Key);
keyList.Add(ecdsa521Key);
keyList.Add(ed25519Key);
allKeys = keyList.AsReadOnly();
}
示例2: ArrangeNestedRegionTest
public void ArrangeNestedRegionTest()
{
List<ICodeElement> elements = new List<ICodeElement>();
TypeElement type = new TypeElement();
type.Type = TypeElementType.Class;
type.Name = "TestClass";
FieldElement field = new FieldElement();
field.Name = "val";
field.Type = "int";
type.AddChild(field);
elements.Add(type);
// Create a configuration with a nested region
CodeConfiguration codeConfiguration = new CodeConfiguration();
ElementConfiguration typeConfiguration = new ElementConfiguration();
typeConfiguration.ElementType = ElementType.Type;
RegionConfiguration regionConfiguration1 = new RegionConfiguration();
regionConfiguration1.Name = "Region1";
RegionConfiguration regionConfiguration2 = new RegionConfiguration();
regionConfiguration2.Name = "Region2";
ElementConfiguration fieldConfiguration = new ElementConfiguration();
fieldConfiguration.ElementType = ElementType.Field;
regionConfiguration2.Elements.Add(fieldConfiguration);
regionConfiguration1.Elements.Add(regionConfiguration2);
typeConfiguration.Elements.Add(regionConfiguration1);
codeConfiguration.Elements.Add(typeConfiguration);
CodeArranger arranger = new CodeArranger(codeConfiguration);
ReadOnlyCollection<ICodeElement> arrangedElements = arranger.Arrange(elements.AsReadOnly());
Assert.AreEqual(1, arrangedElements.Count, "Unexpected number of arranged elements.");
TypeElement arrangedType = arrangedElements[0] as TypeElement;
Assert.IsNotNull(arrangedType, "Expected a type element after arranging.");
Assert.AreEqual(1, arrangedType.Children.Count, "Unexpected number of arranged child elements.");
RegionElement arrangedRegion1 = arrangedType.Children[0] as RegionElement;
Assert.IsNotNull(arrangedRegion1, "Expected a region element after arranging.");
Assert.AreEqual(regionConfiguration1.Name, arrangedRegion1.Name);
Assert.AreEqual(1, arrangedRegion1.Children.Count, "Unexpected number of arranged child elements.");
RegionElement arrangedRegion2 = arrangedRegion1.Children[0] as RegionElement;
Assert.IsNotNull(arrangedRegion2, "Expected a region element after arranging.");
Assert.AreEqual(regionConfiguration2.Name, arrangedRegion2.Name);
Assert.AreEqual(1, arrangedRegion2.Children.Count, "Unexpected number of arranged child elements.");
FieldElement arrangedFieldElement = arrangedRegion2.Children[0] as FieldElement;
Assert.IsNotNull(arrangedFieldElement, "Expected a field element after arranging.");
}
示例3: SlicerPlaneTests
public SlicerPlaneTests()
{
List<IVolumeSlicerParams> slicings = new List<IVolumeSlicerParams>();
slicings.Add(VolumeSlicerParams.Identity);
slicings.Add(VolumeSlicerParams.OrthogonalX);
slicings.Add(VolumeSlicerParams.OrthogonalY);
slicings.Add(new VolumeSlicerParams(0, 90, 45));
slicings.Add(new VolumeSlicerParams(32, -62, 69));
slicings.Add(new VolumeSlicerParams(60, 0, -30));
slicings.Add(new VolumeSlicerParams(-15, 126, -30));
_slicings = slicings.AsReadOnly();
}
示例4: LoadsRecentAccounts
public void LoadsRecentAccounts()
{
var values = new List<RecentAccountInformation>
{
CreateRecentAccountInformation("C:\test\test.txt", new DateTime(2014, 4, 1)),
CreateRecentAccountInformation("C:\test2\test2.txt", new DateTime(2014, 8, 14))
};
ApplicationContext.RecentAccounts.Returns(values.AsReadOnly());
var viewModel = new AccountManagementPageViewModel(Application);
Assert.That(viewModel.Accounts.Count, Is.EqualTo(2));
Assert.That(viewModel.Accounts[0].LastAccessDate, Is.EqualTo(new DateTime(2014, 4, 1)));
Assert.That(viewModel.Accounts[0].Path, Is.EqualTo("C:\test\test.txt"));
Assert.That(viewModel.Accounts[1].LastAccessDate, Is.EqualTo(new DateTime(2014, 8, 14)));
Assert.That(viewModel.Accounts[1].Path, Is.EqualTo("C:\test2\test2.txt"));
}
示例5: ShouldBeAbleToExecuteSimpleJavascriptAndReturnAnArray
public void ShouldBeAbleToExecuteSimpleJavascriptAndReturnAnArray()
{
if (!(driver is IJavaScriptExecutor))
{
return;
}
driver.Url = javascriptPage;
List<object> expectedResult = new List<object>();
expectedResult.Add("zero");
List<object> subList = new List<object>();
subList.Add(true);
subList.Add(false);
expectedResult.Add(subList.AsReadOnly());
object result = ExecuteScript("return ['zero', [true, false]];");
Assert.IsTrue(result is ReadOnlyCollection<object>, "result was: " + result + " (" + result.GetType().Name + ")");
ReadOnlyCollection<object> list = (ReadOnlyCollection<object>)result;
Assert.IsTrue(CompareLists(expectedResult.AsReadOnly(), list));
}
示例6: ShouldBeAbleToExecuteSimpleJavascriptAndReturnAnObjectLiteral
public void ShouldBeAbleToExecuteSimpleJavascriptAndReturnAnObjectLiteral()
{
if (!(driver is IJavaScriptExecutor))
{
return;
}
driver.Url = javascriptPage;
Dictionary<string, object> expectedPerson = new Dictionary<string, object>();
expectedPerson.Add("first", "John");
expectedPerson.Add("last", "Doe");
Dictionary<string, object> expectedResult = new Dictionary<string, object>();
expectedResult.Add("foo", "bar");
List<object> subList = new List<object>() { "a", "b", "c" };
expectedResult.Add("baz", subList.AsReadOnly());
expectedResult.Add("person", expectedPerson);
object result = ExecuteScript(
"return {foo:'bar', baz: ['a', 'b', 'c'], " +
"person: {first: 'John',last: 'Doe'}};");
Assert.IsTrue(result is Dictionary<string, object>, "result was: " + result.GetType().ToString());
Dictionary<string, object> map = (Dictionary<string, object>)result;
Assert.AreEqual(3, map.Count, "Expected:<" + expectedResult.Count + ">, but was:<" + map.Count + ">");
foreach (string expectedKey in expectedResult.Keys)
{
Assert.IsTrue(map.ContainsKey(expectedKey));
}
Assert.AreEqual("bar", map["foo"]);
Assert.IsTrue(CompareLists((ReadOnlyCollection<object>)expectedResult["baz"], (ReadOnlyCollection<object>)map["baz"]));
Dictionary<string, object> person = (Dictionary<string, object>) map["person"];
Assert.AreEqual(2, person.Count);
Assert.AreEqual("John", person["first"]);
Assert.AreEqual("Doe", person["last"]);
}
示例7: AgentTest
static AgentTest()
{
buffer = new byte[4096];
stream = new MemoryStream(buffer);
parser = new BlobParser(stream);
rsa1Key = KeyGenerator.CreateKey(SshVersion.SSH1,
PublicKeyAlgorithm.SSH_RSA, "SSH1 RSA test key");
rsaKey = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.SSH_RSA, "SSH2 RSA test key");
dsaKey = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.SSH_DSS, "SSH2 DSA test key");
ecdsa256Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP256, "SSH2 ECDSA 256 test key");
ecdsa384Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP384, "SSH2 ECDSA 384 test key");
ecdsa521Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ECDSA_SHA2_NISTP521, "SSH2 ECDSA 521 test key");
ed25519Key = KeyGenerator.CreateKey(SshVersion.SSH2,
PublicKeyAlgorithm.ED25519, "SSH2 ED25519 test key");
List<ISshKey> allKeysList = new List<ISshKey>();
allKeysList.Add(rsa1Key);
allKeysList.Add(rsaKey);
allKeysList.Add(dsaKey);
allKeysList.Add(ecdsa256Key);
allKeysList.Add(ecdsa384Key);
allKeysList.Add(ecdsa521Key);
allKeysList.Add(ed25519Key);
allKeys = allKeysList.AsReadOnly();
}
示例8: ArrangeStaticFieldsTest
public void ArrangeStaticFieldsTest()
{
List<ICodeElement> codeElements = new List<ICodeElement>();
TypeElement classElement = new TypeElement();
classElement.Type = TypeElementType.Class;
classElement.Access = CodeAccess.Public;
classElement.Name = "TestClass";
FieldElement fieldElement1 = new FieldElement();
fieldElement1.MemberModifiers = MemberModifiers.Static;
fieldElement1.Access = CodeAccess.Protected;
fieldElement1.Type = "object";
fieldElement1.Name = "_obj";
fieldElement1.InitialValue = "typeof(int).ToString();";
classElement.AddChild(fieldElement1);
// This field has a static dependency. Normally it would be sorted first
// due to its access, but we want to make sure it gets added after the
// field for which it is dependent.
FieldElement fieldElement2 = new FieldElement();
fieldElement2.MemberModifiers = MemberModifiers.Static;
fieldElement2.Access = CodeAccess.Public;
fieldElement2.Type = "bool";
fieldElement2.Name = "Initialized";
fieldElement2.InitialValue = "_initializationString != null";
classElement.AddChild(fieldElement2);
FieldElement fieldElement3 = new FieldElement();
fieldElement3.MemberModifiers = MemberModifiers.Static;
fieldElement3.Access = CodeAccess.Private;
fieldElement3.Type = "string";
fieldElement3.Name = "_initializationString";
fieldElement3.InitialValue = "_obj";
classElement.AddChild(fieldElement3);
codeElements.Add(classElement);
CodeArranger arranger = new CodeArranger(CodeConfiguration.Default);
ReadOnlyCollection<ICodeElement> arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(1, arranged.Count, "After arranging, an unexpected number of elements were returned.");
TypeElement typeElement = arranged[0] as TypeElement;
Assert.IsNotNull(typeElement, "Expected a type element.");
List<FieldElement> staticFields = new List<FieldElement>();
Action<ICodeElement> findStaticFields = delegate(ICodeElement codeElement)
{
FieldElement fieldElement = codeElement as FieldElement;
if (fieldElement != null && fieldElement.MemberModifiers == MemberModifiers.Static)
{
staticFields.Add(fieldElement);
}
};
ElementUtilities.ProcessElementTree(typeElement, findStaticFields);
Assert.AreEqual(3, staticFields.Count, "Unexpected number of static fields after arranging.");
Assert.AreEqual("_obj", staticFields[0].Name);
Assert.AreEqual("_initializationString", staticFields[1].Name);
Assert.AreEqual("Initialized", staticFields[2].Name);
//
// Remove the dependency
//
fieldElement2.InitialValue = "true";
fieldElement3.InitialValue = "\"test\"";
arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(1, arranged.Count, "After arranging, an unexpected number of elements were returned.");
typeElement = arranged[0] as TypeElement;
Assert.IsNotNull(typeElement, "Expected a type element.");
staticFields.Clear();
ElementUtilities.ProcessElementTree(typeElement, findStaticFields);
Assert.AreEqual(3, staticFields.Count, "Unexpected number of static fields after arranging.");
Assert.AreEqual("Initialized", staticFields[0].Name);
Assert.AreEqual("_obj", staticFields[1].Name);
Assert.AreEqual("_initializationString", staticFields[2].Name);
}
示例9: MoveUsingsToNamespaceTest
public void MoveUsingsToNamespaceTest()
{
List<ICodeElement> codeElements = new List<ICodeElement>();
UsingElement using1 = new UsingElement();
using1.Name = "System";
using1.IsMovable = true;
codeElements.Add(using1);
// Nested region and groups
RegionElement region = new RegionElement();
region.Name = "Region";
codeElements.Add(region);
GroupElement group = new GroupElement();
group.Name = "Group";
region.AddChild(group);
UsingElement using2 = new UsingElement();
using2.Name = "System.IO";
using2.IsMovable = true;
group.AddChild(using2);
NamespaceElement namespaceElement = new NamespaceElement();
namespaceElement.Name = "TestNamespace";
codeElements.Add(namespaceElement);
UsingElement using3 = new UsingElement();
using3.Name = "System.Collections";
using3.IsMovable = true;
namespaceElement.AddChild(using3);
TypeElement class1 = new TypeElement();
class1.Name = "Class1";
namespaceElement.AddChild(class1);
TypeElement class2 = new TypeElement();
class2.Name = "Class2";
namespaceElement.AddChild(class2);
CodeConfiguration configuration = CodeConfiguration.Default.Clone() as CodeConfiguration;
CodeArranger arranger;
//
// Move to namespace.
//
configuration.Formatting.Usings.MoveTo = CodeLevel.Namespace;
arranger = new CodeArranger(configuration);
ReadOnlyCollection<ICodeElement> arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(2, arranged.Count, "After arranging, an unexpected number of elements were returned.");
NamespaceElement namespaceElementTest = arranged[1] as NamespaceElement;
Assert.IsNotNull(namespaceElementTest, "Expected a namespace element.");
Assert.AreEqual(2, namespaceElementTest.Children.Count,
"After arranging, an unexpected number of namespace elements were returned.");
GroupElement namespaceGroup = namespaceElementTest.Children[0] as GroupElement;
Assert.IsNotNull(namespaceGroup);
GroupElement innerGroup = namespaceGroup.Children[0] as GroupElement;
Assert.AreEqual("System", innerGroup.Children[0].Name);
Assert.AreEqual("System.Collections", innerGroup.Children[1].Name);
Assert.AreEqual("System.IO", innerGroup.Children[2].Name);
RegionElement typeRegion = namespaceElementTest.Children[1] as RegionElement;
Assert.IsNotNull(typeRegion);
Assert.AreEqual("Class1", typeRegion.Children[0].Name);
Assert.AreEqual("Class2", typeRegion.Children[1].Name);
}
示例10: MoveUsingsBasicTest
public void MoveUsingsBasicTest()
{
List<ICodeElement> codeElements = new List<ICodeElement>();
UsingElement using1 = new UsingElement();
using1.Name = "System";
using1.IsMovable = true;
UsingElement using2 = new UsingElement();
using2.Name = "System.IO";
using2.IsMovable = true;
UsingElement using3 = new UsingElement();
using3.Name = "System.Collections";
using3.IsMovable = true;
codeElements.Add(using1);
codeElements.Add(using2);
NamespaceElement namespaceElement = new NamespaceElement();
namespaceElement.Name = "TestNamespace";
namespaceElement.AddChild(using3);
codeElements.Add(namespaceElement);
CodeConfiguration configuration = CodeConfiguration.Default.Clone() as CodeConfiguration;
CodeArranger arranger;
//
// Do not move.
//
configuration.Formatting.Usings.MoveTo = CodeLevel.None;
arranger = new CodeArranger(configuration);
ReadOnlyCollection<ICodeElement> arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(2, arranged.Count, "After arranging, an unexpected number of elements were returned.");
GroupElement fileGroup = arranged[0] as GroupElement;
Assert.IsNotNull(fileGroup);
GroupElement innerGroup = fileGroup.Children[0] as GroupElement;
Assert.AreEqual("System", innerGroup.Children[0].Name);
Assert.AreEqual("System.IO", innerGroup.Children[1].Name);
NamespaceElement namespaceElementTest = arranged[1] as NamespaceElement;
Assert.IsNotNull(namespaceElementTest, "Expected a namespace element.");
Assert.AreEqual(1, namespaceElementTest.Children.Count,
"After arranging, an unexpected number of namespace elements were returned.");
GroupElement namespaceGroup = namespaceElementTest.Children[0] as GroupElement;
Assert.IsNotNull(namespaceGroup);
innerGroup = namespaceGroup.Children[0] as GroupElement;
Assert.AreEqual("System.Collections", innerGroup.Children[0].Name);
//
// Move to file level;
//
configuration.Formatting.Usings.MoveTo = CodeLevel.File;
arranger = new CodeArranger(configuration);
arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(2, arranged.Count, "After arranging, an unexpected number of elements were returned.");
fileGroup = arranged[0] as GroupElement;
Assert.IsNotNull(fileGroup);
innerGroup = fileGroup.Children[0] as GroupElement;
Assert.AreEqual("System", innerGroup.Children[0].Name);
Assert.AreEqual("System.Collections", innerGroup.Children[1].Name);
Assert.AreEqual("System.IO", innerGroup.Children[2].Name);
namespaceElementTest = arranged[1] as NamespaceElement;
Assert.IsNotNull(namespaceElementTest, "Expected a namespace element.");
//
// Move to namespace.
//
configuration.Formatting.Usings.MoveTo = CodeLevel.Namespace;
arranger = new CodeArranger(configuration);
arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(1, arranged.Count, "After arranging, an unexpected number of elements were returned.");
namespaceElementTest = arranged[0] as NamespaceElement;
Assert.IsNotNull(namespaceElementTest, "Expected a namespace element.");
Assert.AreEqual(1, namespaceElementTest.Children.Count,
"After arranging, an unexpected number of namespace elements were returned.");
namespaceGroup = namespaceElementTest.Children[0] as GroupElement;
Assert.IsNotNull(namespaceGroup);
innerGroup = namespaceGroup.Children[0] as GroupElement;
Assert.AreEqual("System", innerGroup.Children[0].Name);
Assert.AreEqual("System.Collections", innerGroup.Children[1].Name);
Assert.AreEqual("System.IO", innerGroup.Children[2].Name);
//
// Move back to file level;
//
configuration.Formatting.Usings.MoveTo = CodeLevel.File;
arranger = new CodeArranger(configuration);
arranged = arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(2, arranged.Count, "After arranging, an unexpected number of elements were returned.");
//.........這裏部分代碼省略.........
示例11: PersonMerge
public void PersonMerge()
{
var singlePersonMergeData = new MergeTestData
{
FullName = "Johnny Rockets, King of the Dinosaurs",
Things =
new List<MergeTestData.Thing>(
new[]
{
new MergeTestData.Thing { TheValue = "Something" }, new MergeTestData.Thing { TheValue = "Another thing" },
new MergeTestData.Thing { TheValue = "One more thing" }, new MergeTestData.Thing { TheValue = "Last thing" },
new MergeTestData.Thing { TheValue = "Okay THIS is the last thing" }, new MergeTestData.Thing { TheValue = "Something again" },
new MergeTestData.Thing { TheValue = "Another thing again" }, new MergeTestData.Thing { TheValue = "One more thing again" },
new MergeTestData.Thing { TheValue = "Last thing again" }, new MergeTestData.Thing { TheValue = "Okay THIS is the last thing again" },
new MergeTestData.Thing { TheValue = "Something one more time" }, new MergeTestData.Thing { TheValue = "Another thing one more time" },
new MergeTestData.Thing { TheValue = "One more thing one more time" }, new MergeTestData.Thing { TheValue = "Last thing one more time" },
new MergeTestData.Thing { TheValue = "Okay THIS is the last thing one more time" },
new MergeTestData.Thing { TheValue = "Something that is getting old" }, new MergeTestData.Thing { TheValue = "Another thing that is getting old" },
new MergeTestData.Thing { TheValue = "One more thing that is getting old" }, new MergeTestData.Thing { TheValue = "Last thing that is getting old" },
new MergeTestData.Thing { TheValue = "Okay THIS is the last thing that is getting old" },
new MergeTestData.Thing { TheValue = "Something about the end of all things" },
new MergeTestData.Thing { TheValue = "Another thing about the end of all things" },
new MergeTestData.Thing { TheValue = "One more thing about the end of all things" },
new MergeTestData.Thing { TheValue = "Last thing about the end of all things" },
new MergeTestData.Thing { TheValue = "Okay THIS is the last thing about the end of all things" },
} )
};
var mergingInfoFields = new List<MergeField<MergeTestData>>( new[] { MergeFieldOps.CreateBasicField( new FullName() ) } );
var internalTableDataFields = new List<MergeField<MergeTestData.Thing>>( new[] { MergeFieldOps.CreateBasicField( new TheValue() ) } );
var mergeTree = MergeDataTreeOps.CreateRowTree(
mergingInfoFields.AsReadOnly(),
singlePersonMergeData.ToSingleElementArray(),
new List<MergeDataTreeChild<MergeTestData>>
{
new MergeDataTreeChild<MergeTestData, MergeTestData.Thing>( "Things", internalTableDataFields.AsReadOnly(), info => info.Things )
}.AsReadOnly() );
using( var templateStream = File.OpenRead( testingWordTemplatePath ) ) {
using( var destinationStream = File.Create( getFilePath( "basic_merge_test" ) ) ) {
MergeOps.CreateMsWordDoc( mergeTree, true, templateStream, destinationStream );
doneCreating = DateTime.Now;
}
}
}
示例12: DicomAttributeEmptyNullTestSuite
public DicomAttributeEmptyNullTestSuite() {
uint tag = 0x2101FF00;
List<DicomTag> tags = new List<DicomTag>();
foreach (DicomVr vr in DicomVr.GetDicomVrList()) {
tags.Add(new DicomTag(tag++, "dummy-tag-" + vr.Name, "dummy_tag_" + vr.Name, vr, false, 1, 1, false));
tags.Add(new DicomTag(tag++, "dummy-mvtag-" + vr.Name, "dummy_mvtag_" + vr.Name, vr, false, 0, 10, false));
}
_tags = tags.AsReadOnly();
}
示例13: DefaultArrangeEnumerationTest
public void DefaultArrangeEnumerationTest()
{
List<ICodeElement> codeElements = new List<ICodeElement>();
UsingElement usingElement = new UsingElement();
usingElement.Name = "System";
TypeElement enumElement = new TypeElement();
enumElement.Type = TypeElementType.Enum;
enumElement.Access = CodeAccess.Public;
enumElement.Name = "TestEnum";
enumElement.BodyText = "Value1 = 1,\r\nValue2 = 2";
NamespaceElement namespaceElement = new NamespaceElement();
namespaceElement.Name = "TestNamespace";
namespaceElement.AddChild(usingElement);
namespaceElement.AddChild(enumElement);
codeElements.Add(namespaceElement);
CodeArranger arranger = new CodeArranger(CodeConfiguration.Default);
ReadOnlyCollection<ICodeElement> arranged =
arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(1, arranged.Count, "After arranging, an unexpected number of elements were returned.");
NamespaceElement namespaceElementTest = arranged[0] as NamespaceElement;
Assert.IsNotNull(namespaceElementTest, "Expected a namespace element.");
Assert.AreEqual(2, namespaceElementTest.Children.Count,
"After arranging, an unexpected number of namespace elements were returned.");
Assert.AreEqual(ElementType.Using, namespaceElement.Children[0].ElementType);
RegionElement regionElement = namespaceElementTest.Children[1] as RegionElement;
Assert.IsNotNull(regionElement, "Expected a region element.");
Assert.AreEqual("Enumerations", regionElement.Name, "Unexpected region name.");
Assert.AreEqual(1, regionElement.Children.Count,
"After arranging, an unexpected number of region elements were returned.");
TypeElement typeElement = regionElement.Children[0] as TypeElement;
Assert.IsNotNull(typeElement, "Expected a type element.");
Assert.AreEqual(TypeElementType.Enum, typeElement.Type, "Unexpected type element type.");
Assert.AreEqual(enumElement.Name, typeElement.Name, "Unexpected type element name.");
}
示例14: OpenRecentAccount
public void OpenRecentAccount()
{
var values = new List<RecentAccountInformation>
{
CreateRecentAccountInformation(@"C:\test\test.txt", new DateTime(2014, 4, 1)),
};
ApplicationContext.RecentAccounts.Returns(values.AsReadOnly());
var viewModel = new AccountManagementPageViewModel(Application);
viewModel.Accounts.First().OpenCommand.Execute(null);
Repository.Received(1).Open(@"C:\test\test.txt");
Repository.Received(1).UpdateStandingOrdersToCurrentMonth();
ApplicationContext.DidNotReceiveWithAnyArgs().UpdateRecentAccountInformation(@"C:\test\test.txt");
Assert.That(Application.ActivePage, Is.InstanceOf<RequestManagementPageViewModel>());
}
示例15: DefaultArrangeConditionDirectiveTest
public void DefaultArrangeConditionDirectiveTest()
{
List<ICodeElement> codeElements = new List<ICodeElement>();
ConditionDirectiveElement ifCondition = new ConditionDirectiveElement();
ifCondition.ConditionExpression = "DEBUG";
FieldElement field1 = new FieldElement();
field1.Name = "zField";
field1.Type = "int";
FieldElement field2 = new FieldElement();
field2.Name = "aField";
field2.Type = "int";
ifCondition.AddChild(field1);
ifCondition.AddChild(field2);
ifCondition.ElseCondition = new ConditionDirectiveElement();
FieldElement field3 = new FieldElement();
field3.Name = "testField";
field3.Type = "int";
FieldElement field1Clone = field1.Clone() as FieldElement;
FieldElement field2Clone = field2.Clone() as FieldElement;
TypeElement classElement = new TypeElement();
classElement.Name = "TestClass";
classElement.AddChild(field1Clone);
classElement.AddChild(field2Clone);
ifCondition.ElseCondition.AddChild(field3);
ifCondition.ElseCondition.AddChild(classElement);
codeElements.Add(ifCondition);
CodeArranger arranger = new CodeArranger(CodeConfiguration.Default);
ReadOnlyCollection<ICodeElement> arranged =
arranger.Arrange(codeElements.AsReadOnly());
Assert.AreEqual(1, arranged.Count, "After arranging, an unexpected number of elements were returned.");
ConditionDirectiveElement ifConditionTest = arranged[0] as ConditionDirectiveElement;
Assert.IsNotNull(ifConditionTest, "Expected a condition directive element.");
Assert.AreEqual(2, ifConditionTest.Children.Count,
"After arranging, an unexpected number of nested elements were returned.");
Assert.AreEqual(field2.Name, ifConditionTest.Children[0].Name);
Assert.AreEqual(field1.Name, ifConditionTest.Children[1].Name);
ConditionDirectiveElement elseConditionTest = ifConditionTest.ElseCondition;
Assert.IsNotNull(elseConditionTest, "Expected a condition directive element.");
Assert.AreEqual(2, ifConditionTest.Children.Count,
"After arranging, an unexpected number of nested elements were returned.");
Assert.AreEqual(field3.Name, elseConditionTest.Children[0].Name);
Assert.AreEqual(classElement.Name, elseConditionTest.Children[1].Name);
TypeElement classElementTest = elseConditionTest.Children[1] as TypeElement;
Assert.IsNotNull(classElementTest, "Expected a type element.");
Assert.AreEqual(1, classElementTest.Children.Count);
Assert.AreEqual("Fields", classElementTest.Children[0].Name);
}