本文整理汇总了C#中NUnit.Framework.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndDisposeExplicitSetting
public void CreateAndDisposeExplicitSetting(ReferenceHandling referenceHandling)
{
var x = new WithSimpleProperties { Value = 1, Time = DateTime.MinValue };
var y = new WithSimpleProperties { Value = 1, Time = DateTime.MinValue };
var propertyChanges = new List<string>();
var expectedChanges = new List<string>();
using (var tracker = Track.IsDirty(x, y, PropertiesSettings.GetOrCreate(referenceHandling)))
{
tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
Assert.AreEqual(false, tracker.IsDirty);
Assert.AreEqual(null, tracker.Diff);
CollectionAssert.IsEmpty(propertyChanges);
x.Value++;
Assert.AreEqual(true, tracker.IsDirty);
Assert.AreEqual("WithSimpleProperties Value x: 2 y: 1", tracker.Diff.ToString("", " "));
expectedChanges.AddRange(new[] { "Diff", "IsDirty" });
CollectionAssert.AreEqual(expectedChanges, propertyChanges);
}
x.Value++;
CollectionAssert.AreEqual(expectedChanges, propertyChanges);
#if (!DEBUG) // debug build keeps instances alive longer for nicer debugging experience
var wrx = new System.WeakReference(x);
var wry = new System.WeakReference(y);
x = null;
y = null;
System.GC.Collect();
Assert.AreEqual(false, wrx.IsAlive);
Assert.AreEqual(false, wry.IsAlive);
#endif
}
示例2: DailyAuditLogs
//[Test]
public void DailyAuditLogs()
{
var list = new List<AuditLogDisplay>();
var merchello = new MerchelloHelper();
var invoice = merchello.Query.Invoice.GetByKey(new Guid("85F6F194-2F74-4CD5-9CE8-98723B50E719"));
var _auditLogService = MerchelloContext.Current.Services.AuditLogService;
if (invoice != null)
{
Console.WriteLine("Got an invoice");
var invoiceLogs = _auditLogService.GetAuditLogsByEntityKey(invoice.Key).Select(x => x.ToAuditLogDisplay()).ToArray();
if (invoiceLogs.Any()) list.AddRange(invoiceLogs);
foreach (var orderLogs in invoice.Orders.Select(order => _auditLogService.GetAuditLogsByEntityKey(order.Key).Select(x => x.ToAuditLogDisplay()).ToArray()).Where(orderLogs => orderLogs.Any()))
{
list.AddRange(orderLogs);
}
var paymentKeys = MerchelloContext.Current.Services.PaymentService.GetPaymentsByInvoiceKey(invoice.Key).Select(x => x.Key);
foreach (var paymentLogs in paymentKeys.Select(x => _auditLogService.GetAuditLogsByEntityKey(x).Select(log => log.ToAuditLogDisplay())).ToArray())
{
list.AddRange(paymentLogs);
}
}
Console.WriteLine(JsonConvert.SerializeObject(list.ToSalesHistoryDisplay()));
}
示例3: CreateData
private List<LicenseDataGridViewRow> CreateData(int numberThatCanActivate, int numberThatCannotActivate)
{
List<LicenseDataGridViewRow> data = new List<LicenseDataGridViewRow>();
data.AddRange(Enumerable.Repeat(CreateRow(true), numberThatCanActivate));
data.AddRange(Enumerable.Repeat(CreateRow(false), numberThatCannotActivate));
return data;
}
示例4: ScopeTextBox
public void ScopeTextBox()
{
var groupBox = this.Window.GetByText<GroupBox>("Scope textbox events");
var expected = new List<string> { "HasError: False", "Empty" };
var actual = groupBox.GetMultiple<Label>("Event").Select(x => x.Text).ToArray();
CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}");
var textBox = this.Window.Get<TextBox>("ScopeTextBox");
textBox.Enter('a');
this.Window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
expected.AddRange(new[]
{
"ValidationError: Value 'a' could not be converted.",
"HasError: True",
"Action: Added Error: Value 'a' could not be converted. Source: ScopeTextBox OriginalSource: ScopeTextBox"
});
actual = groupBox.GetMultiple<Label>("Event").Select(x => x.Text).ToArray();
CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}");
textBox.Text = "1";
this.Window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
expected.AddRange(new[]
{
"HasError: False",
"Empty",
"Action: Removed Error: Value 'a' could not be converted. Source: ScopeTextBox OriginalSource: ScopeTextBox"
});
actual = groupBox.GetMultiple<Label>("Event").Select(x => x.Text).ToArray();
CollectionAssert.AreEqual(expected, actual, $"Actual: {string.Join(", ", actual.Select(x => "\"" + x + "\""))}");
}
示例5: IntervalTimePerTimeValuesAttribute
static IntervalTimePerTimeValuesAttribute()
{
var values = new List<IQuantity>();
var times = new[]
{
//TODO: ... however, us, ms, s, min, hr, are not unreasonable to expect ...
T.Microsecond,
T.Millisecond,
T.Second,
T.Minute,
T.Hour,
////TODO: we do not care about Days or Weeks for purposes of these tests...
//T.Day,
//T.Week,
};
// TODO: TBD: Avoid scaling too absurdly: may want to be more selective than this...
var length = times.Length - 2;
// TODO: TBD: Could also vary the value itself, but this will do for starters...
const double value = 1e2;
var first = times.Take(length).ToArray();
var second = times.Reverse().Take(length).ToArray();
values.AddRange(from x in first from y in second select new Quantity(value, x, y.Invert()));
values.AddRange(from y in first from x in second select new Quantity(value, x, y.Invert()));
Values = values.OfType<object>().ToArray();
}
示例6: AddSameToBoth
public void AddSameToBoth()
{
var x = new ObservableCollection<int>();
var y = new ObservableCollection<int>();
var changes = new List<string>();
var expectedChanges = new List<string>();
using (var tracker = Track.IsDirty(x, y))
{
tracker.PropertyChanged += (_, e) => changes.Add(e.PropertyName);
Assert.AreEqual(false, tracker.IsDirty);
Assert.AreEqual(null, tracker.Diff);
CollectionAssert.IsEmpty(changes);
x.Add(1);
Assert.AreEqual(true, tracker.IsDirty);
Assert.AreEqual("ObservableCollection<int> [0] x: 1 y: missing item", tracker.Diff.ToString("", " "));
expectedChanges.AddRange(new[] { "Diff", "IsDirty" });
CollectionAssert.AreEqual(expectedChanges, changes);
y.Add(1);
Assert.AreEqual(false, tracker.IsDirty);
Assert.AreEqual(null, tracker.Diff);
expectedChanges.AddRange(new[] { "Diff", "IsDirty" });
CollectionAssert.AreEqual(expectedChanges, changes);
}
}
示例7: should_correctly_read_tile
public void should_correctly_read_tile()
{
var dummyDescriptor = new TISDescriptor();
dummyDescriptor.TileDimensions = 2;
var dummyColour = new TISColour { B = 255, G = 255, R = 255, A = 255 };
var dummyPalette = new List<TISColour>();
for (int i = 0; i < 256; i++)
{ dummyPalette.Add(dummyColour); }
var dummyPixels = new List<byte>();
for (byte i = 0; i < dummyDescriptor.TileDimensions * 2; i++)
{ dummyPixels.Add(i); }
var expectedOutput = new TISTile(dummyPalette, dummyPixels, dummyDescriptor.TileDimensions);
var plugin = new TISPlugin();
var tileBytes = new List<byte>();
foreach(var colour in dummyPalette)
{ tileBytes.AddRange(new[] { colour.A, colour.R, colour.G, colour.B }); }
tileBytes.AddRange(dummyPixels);
var memoryStream = new MemoryStream(tileBytes.ToArray());
var binaryReader = new BinaryReader(memoryStream);
var createTileMethod = plugin.GetType().GetMethod("ReadTile", BindingFlags.NonPublic | BindingFlags.Instance);
var result = createTileMethod.Invoke(plugin, new object[] { binaryReader, dummyDescriptor });
Assert.That(result, Is.EqualTo(expectedOutput));
}
示例8: VerifyExceptionConventions
public void VerifyExceptionConventions()
{
var exceptionTypes = new List<Type>();
exceptionTypes.AddRange(GetExceptionTypes(typeof(IMessage).Assembly));
exceptionTypes.AddRange(GetExceptionTypes(typeof(UnicastBus).Assembly));
foreach (var exceptionType in exceptionTypes)
{
if (exceptionType.GetCustomAttribute<ObsoleteAttribute>() !=null )
{
continue;
}
Assert.IsTrue(exceptionType.IsPublic, string.Format("Exception '{0}' should be public", exceptionType.Name));
var constructor = exceptionType.GetConstructor(BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null);
Assert.IsNotNull(constructor, string.Format("Exception '{0}' should implement 'protected {0}(SerializationInfo info, StreamingContext context){{}}'", exceptionType.Name));
var serializableAttribute = exceptionType.GetCustomAttributes(typeof(SerializableAttribute), false).FirstOrDefault();
Assert.IsNotNull(serializableAttribute, string.Format("Exception '{0}' should have a 'SerializableAttribute'", exceptionType.Name));
var properties = exceptionType.GetProperties(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);
if (properties.Length > 0)
{
var getObjectDataMethod = exceptionType.GetMethod("GetObjectData");
Assert.IsTrue(getObjectDataMethod.DeclaringType.Name != "Exception", string.Format("Exception '{0}' has properties and as such should override 'GetObjectData'", exceptionType.Name));
}
}
}
示例9: Find
public void Find()
{
var list = new List<int>();
list.AddRange(new[] { 3, 4, 76, 34, 50, 23, 45 });
var visitor = new ComparableFindingVisitor<int>(50);
list.AcceptVisitor(visitor);
Assert.IsTrue(visitor.Found);
Assert.IsTrue(visitor.HasCompleted);
visitor = new ComparableFindingVisitor<int>(50);
list.Clear();
list.AddRange(new[] { 50, 3, 4, 76, 34, 23, 45 });
list.AcceptVisitor(visitor);
Assert.IsTrue(visitor.Found);
Assert.IsTrue(visitor.HasCompleted);
visitor = new ComparableFindingVisitor<int>(50);
list.Clear();
list.AddRange(new[] { 3, 4, 76, 34, 23, 45, 50 });
list.AcceptVisitor(visitor);
Assert.IsTrue(visitor.Found);
Assert.IsTrue(visitor.HasCompleted);
visitor = new ComparableFindingVisitor<int>(50);
list.Clear();
list.AddRange(new[] { 3, 4, 76, 34, 23, 45 });
list.AcceptVisitor(visitor);
Assert.IsFalse(visitor.Found);
Assert.IsFalse(visitor.HasCompleted);
}
示例10: TestGetActions
public void TestGetActions()
{
IPolicySet policySet = ReadPolicySet(m_testPath + "FileTypesAndActions.policy");
Assert.AreEqual(1, policySet.Policies.Count);
IPolicy policy = policySet.Policies[0];
//Check SMTP channel
List<CellActionsCollection> collections = ExpressionHelpers.GetActions(policy.Channels[0], policySet, false);
List<Workshare.Policy.ObjectModel.IAction> actions = new List<Workshare.Policy.ObjectModel.IAction>();
foreach (CellActionsCollection collection in collections)
actions.AddRange(collection.Actions);
Assert.AreEqual(2, actions.Count);
Assert.AreEqual("Alert Action", actions[0].Name.Value);
Assert.AreEqual("Block Action", actions[1].Name.Value);
//Check Active Content channel
collections = ExpressionHelpers.GetActions(policy.Channels[1], policySet, false);
actions.Clear();
foreach (CellActionsCollection collection in collections)
actions.AddRange(collection.Actions);
Assert.AreEqual(1, actions.Count);
Assert.AreEqual("Alert Action", actions[0].Name.Value);
}
示例11: CalculateEquityCurve
public void CalculateEquityCurve()
{
var deals = new List<MarketOrder>();
var dealsOpen = TestDataGenerator.GetOpenPosition().Select(LinqToEntity.DecorateOrder).ToList();
var dealsClose = TestDataGenerator.GetClosePosition().Select(LinqToEntity.DecorateOrder).ToList();
deals.AddRange(dealsOpen);
deals.AddRange(dealsClose);
var transfers = TestDataGenerator.GetBalanceChange().Select(LinqToEntity.DecorateBalanceChange).ToList();
var firstDealOpenedTime = deals.Min(d => d.TimeEnter);
transfers.Insert(0, new BalanceChange
{
AccountID = deals[0].AccountID,
ValueDate = firstDealOpenedTime.AddHours(-1),
CurrencyToDepoRate = 1,
ChangeType = BalanceChangeType.Deposit,
Amount = 500000
});
var dicQuote = new Dictionary<string, List<QuoteData>>();
foreach (var smb in DalSpot.Instance.GetTickerNames())
dicQuote.Add(smb, dailyQuoteStorage.GetQuotes(smb).Select(q => new QuoteData(q.b, q.b, q.a)).ToList());
var quoteArc = new QuoteArchive(dicQuote);
var res = curveCalculator.CalculateEquityCurve(deals, DepoCurrency, quoteArc, transfers);
// сверить точку кривой доходности
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 0);
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 10);
CheckEquityCurvePoint(res, transfers, dealsOpen, dealsClose, quoteArc, dicQuote, 40);
}
示例12: ObjectMapTest
public void ObjectMapTest()
{
//String[] items = {"camera", "film"};
//String[] discounts = {"nodiscount", "nodiscount"};
//PurchaseOrder po = new PurchaseOrder(items, discounts);
//PurchaseOrder po1 = new PurchaseOrder(items, discounts);
CustomerTestClass cust = new CustomerTestClass();
CustomerTestClass cust2 = new CustomerTestClass();
LocationTestClass theLoc = new LocationTestClass("1", "root location");
cust.IntVal = 4;
cust.TheLocation.Description = "first location";
cust2.TheLocation.Description = "second location";
cust2.TheLocation.ID = "3";
Stream mapStream = this.GetType().Assembly.GetManifestResourceStream("Expergent.Tester.ObjectMap.xml");
StreamReader mapReader = new StreamReader(mapStream);
ObjectMapTable theTable = new ObjectMapTable(mapReader);
Agenda agenda = new Agenda();
List<WME> facts = new List<WME>();
facts.AddRange(agenda.CreateFactSetFromObjectInstance(new ObjectInstance("CustomerTestClass", cust), theTable));
facts.AddRange(agenda.CreateFactSetFromObjectInstance(new ObjectInstance("CustomerTestClass", cust2), theTable));
facts.AddRange(agenda.CreateFactSetFromObjectInstance(new ObjectInstance("LocationTestClass", theLoc), theTable));
facts.AddRange(agenda.CreateFactSetFromObjectInstance(new ObjectInstance("MyClass", this), theTable));
Assert.IsTrue(facts.Count == 31, "Wrong # of facts.");
}
示例13: Setup
public void Setup()
{
var assembler = new TestRunInfoAssembler();
var entries = new List<ProfilerEntry>
{
new ProfilerEntry {Type = ProfileType.Enter, Functionid = 0, Method = "Test1", Runtime = "Test", Sequence = 1, IsTest = true},
};
for (int i = 0; i < 5000; i++)
{
entries.AddRange(new[]
{
new ProfilerEntry {Type = ProfileType.Enter, Functionid = i + 1, Method = "Method" + i, Runtime = "MethodR" + i, Sequence = 1, IsTest = false},
});
}
for (int i = 4999; i >=0; i--)
{
entries.AddRange(new[]
{
new ProfilerEntry {Type = ProfileType.Leave, Functionid = i + 1, Method = "Method" + i, Runtime = "MethodR" + i, Sequence = 1, IsTest = false},
});
}
entries.AddRange(new[] {
new ProfilerEntry {Type = ProfileType.Leave, Functionid = 0, Method = "Test1", Runtime = "Test", Sequence = 5, IsTest = true},
});
items = assembler.Assemble(entries).ToList();
}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:26,代码来源:when_build_test_run_information_with_test_with_depth_more_than_twohundred.cs
示例14: FixtureSetup
public void FixtureSetup()
{
//Get files from the standard locations and move them, using file restorer
List<string> filelocations = new List<string>();
if (Directory.Exists(LocalPolicyCache.LOCAL_BASEPATH_USER))
filelocations.AddRange(Directory.GetFiles(LocalPolicyCache.LOCAL_BASEPATH_USER));
else
{
Directory.CreateDirectory(LocalPolicyCache.LOCAL_BASEPATH_USER);
Assert.IsTrue(Directory.Exists(LocalPolicyCache.LOCAL_BASEPATH_USER), "Failed to set up the folder. This is a bad thing.");
}
if (Directory.Exists(LocalPolicyCache.LOCAL_BASEPATH_COMMON))
filelocations.AddRange(Directory.GetFiles(LocalPolicyCache.LOCAL_BASEPATH_COMMON));
else
{
Directory.CreateDirectory(LocalPolicyCache.LOCAL_BASEPATH_COMMON);
Assert.IsTrue(Directory.Exists(LocalPolicyCache.LOCAL_BASEPATH_COMMON), "Failed to set up the folder. This is a bad thing.");
}
foreach (string location in filelocations)
{
m_filesToRestore.Add(new FileRestorer(location));
}
}
示例15: GetAllAssemblies
private List<Assembly> GetAllAssemblies(string path)
{
var files = new List<FileInfo>();
var directoryToSearch = new DirectoryInfo(path);
files.AddRange(directoryToSearch.GetFiles("*.dll", SearchOption.AllDirectories));
files.AddRange(directoryToSearch.GetFiles("*.exe", SearchOption.AllDirectories));
return files.ConvertAll(file => Assembly.LoadFile(file.FullName));
}