本文整理汇总了C#中NUnit.Framework.List.Last方法的典型用法代码示例。如果您正苦于以下问题:C# List.Last方法的具体用法?C# List.Last怎么用?C# List.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Indicator_Chaining_MAofMA
public void Indicator_Chaining_MAofMA()
{
var results1 = new List<DataPoint<decimal>>();
var results2 = new List<DataPoint<decimal>>();
var ma1 = new MovingAverageIndicator(2);
var ma2 = new MovingAverageIndicator(2);
ma1.Subscribe(ma2); // ma2 of ma1
ma1.Subscribe(results1.Add);
ma2.Subscribe(results2.Add);
ma1.OnNext(new DataPoint<decimal>(DateTime.Now, 1));
ma1.OnNext(new DataPoint<decimal>(DateTime.Now, 2));
Assert.That(results1.Last().Value, Is.EqualTo(1.5));
Assert.That(results2.Any(), Is.EqualTo(false));
ma1.OnNext(new DataPoint<decimal>(DateTime.Now, 3));
Assert.That(results1.Last().Value, Is.EqualTo(2.5));
Assert.That(results2.Last().Value, Is.EqualTo(2));
ma1.OnNext(new DataPoint<decimal>(DateTime.Now, 4));
Assert.That(results1.Last().Value, Is.EqualTo(3.5));
Assert.That(results2.Last().Value, Is.EqualTo(3));
ma1.OnNext(new DataPoint<decimal>(DateTime.Now, 5));
Assert.That(results1.Last().Value, Is.EqualTo(4.5));
Assert.That(results2.Last().Value, Is.EqualTo(4));
ma1.Dispose();
ma2.Dispose();
}
示例2: LawOfResistorsInSeriesTest
public void LawOfResistorsInSeriesTest(int in0)
{
Circuit sim = new Circuit();
var volt0 = sim.Create<DCVoltageSource>();
var volt1 = sim.Create<DCVoltageSource>();
var resCompare = sim.Create<Resistor>(in0 * 100);
List<Resistor> resistors = new List<Resistor>();
for(int i = 0; i < in0; i++)
resistors.Add(sim.Create<Resistor>());
sim.Connect(volt0.leadPos, resistors.First().leadIn);
for(int i = 1; i < in0 - 1; i++)
sim.Connect(resistors[i - 1].leadOut, resistors[i].leadIn);
sim.Connect(volt0.leadNeg, resistors.Last().leadOut);
sim.Connect(volt1.leadPos, resCompare.leadIn);
sim.Connect(resCompare.leadOut, volt1.leadNeg);
sim.doTicks(100);
Assert.AreEqual(Math.Round(resistors.Last().getCurrent(), 12), Math.Round(resCompare.getCurrent(), 12));
}
示例3: ProducesValues
public void ProducesValues()
{
var sut = new MovingAverageIndicator(3);
var results = new List<DataPoint<decimal>>();
using (sut.Subscribe(results.Add))
{
sut.OnNext(new DataPoint<decimal>(DateTime.Now, 1));
Assert.That(results.Count, Is.EqualTo(0));
sut.OnNext(new DataPoint<decimal>(DateTime.Now, 2));
Assert.That(results.Count, Is.EqualTo(0));
sut.OnNext(new DataPoint<decimal>(DateTime.Now, 3));
Assert.That(results.Count, Is.EqualTo(1));
Assert.That(results.Last().Value, Is.EqualTo(2));
sut.OnNext(new DataPoint<decimal>(DateTime.Now, 4));
Assert.That(results.Count, Is.EqualTo(2));
Assert.That(results.Last().Value, Is.EqualTo(3));
sut.OnNext(new DataPoint<decimal>(DateTime.Now, 2));
Assert.That(results.Count, Is.EqualTo(3));
Assert.That(results.Last().Value, Is.EqualTo(3));
sut.Dispose();
}
}
示例4: Couper
public void Couper()
{
var jeu = new List<Carte>(Paquet.TrenteDeuxCartes);
jeu.Melanger();
var anciennePremiere = jeu.First();
var ancienneDerniere = jeu.Last();
jeu = jeu.Couper();
Check.That(jeu).HasSize(32);
Check.That(jeu.First()).IsNotEqualTo(anciennePremiere);
Check.That(jeu.Last()).IsNotEqualTo(ancienneDerniere);
//Validation d'unicité des cartes
var hashSet = new HashSet<Carte>(jeu);
Check.That(hashSet).HasSize(32);
}
示例5: Can_report_progress_when_downloading_async
public async Task Can_report_progress_when_downloading_async()
{
var hold = AsyncServiceClient.BufferSize;
AsyncServiceClient.BufferSize = 100;
try
{
var asyncClient = new JsonServiceClient(ListeningOn);
var progress = new List<string>();
//Note: total = -1 when 'Transfer-Encoding: chunked'
//Available in ASP.NET or in HttpListener when downloading responses with known lengths:
//E.g: Strings, Files, etc.
asyncClient.OnDownloadProgress = (done, total) =>
progress.Add("{0}/{1} bytes downloaded".Fmt(done, total));
var response = await asyncClient.GetAsync(new TestProgress());
progress.Each(x => x.Print());
Assert.That(response.Length, Is.GreaterThan(0));
Assert.That(progress.Count, Is.GreaterThan(0));
Assert.That(progress.First(), Is.EqualTo("100/1160 bytes downloaded"));
Assert.That(progress.Last(), Is.EqualTo("1160/1160 bytes downloaded"));
}
finally
{
AsyncServiceClient.BufferSize = hold;
}
}
示例6: Index_WhenCalls_SetsUpViewModelWithAllContentDescriptorsAndSelectedList
public void Index_WhenCalls_SetsUpViewModelWithAllContentDescriptorsAndSelectedList()
{
List<ESRBContentDescriptor> selectedContentDescriptors = new List<ESRBContentDescriptor>();
List<ESRBContentDescriptor> allContentDescriptors = new List<ESRBContentDescriptor>
{
new ESRBContentDescriptor(),
new ESRBContentDescriptor()
};
Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
Mock<DbSet<ESRBContentDescriptor>> contentDescriptorsDbSetStub = TestHelpers.GetFakeAsyncDbSet(allContentDescriptors.AsQueryable());
dbStub.
Setup(db => db.ESRBContentDescriptors).
Returns(contentDescriptorsDbSetStub.Object);
ESRBDescriptionController controller = new ESRBDescriptionController(dbStub.Object);
var result = controller.Index(selectedContentDescriptors);
Assert.That(result != null);
Assert.That(result.Model, Is.InstanceOf<ESRBDescriptionViewModel>());
var model = (ESRBDescriptionViewModel)result.Model;
Assert.That(model.Selected, Is.SameAs(selectedContentDescriptors));
Assert.That(model.All.Count(), Is.EqualTo(allContentDescriptors.Count));
Assert.That(model.All, Has.Member(allContentDescriptors.First()).And.Member(allContentDescriptors.Last()));
}
示例7: Index_WhenCalls_SetsUpViewModelWithAllPlatformsAndSelectedList
public void Index_WhenCalls_SetsUpViewModelWithAllPlatformsAndSelectedList()
{
List<Platform> selectedPlatforms = new List<Platform>();
List<Platform> allPlatforms = new List<Platform>
{
new Platform(),
new Platform()
};
Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
Mock<DbSet<Platform>> platformDbSetStub = TestHelpers.GetFakeAsyncDbSet(allPlatforms.AsQueryable());
dbStub.
Setup(db => db.Platforms).
Returns(platformDbSetStub.Object);
PlatformsController controller = new PlatformsController(dbStub.Object);
var result = controller.Index(selectedPlatforms);
Assert.That(result != null);
Assert.That(result.Model, Is.InstanceOf<PlatformViewModel>());
var model = (PlatformViewModel) result.Model;
Assert.That(model.Selected, Is.SameAs(selectedPlatforms));
Assert.That(model.AllPlatforms.Count(), Is.EqualTo(allPlatforms.Count));
Assert.That(model.AllPlatforms, Has.Member(allPlatforms.First()).And.Member(allPlatforms.Last()));
}
示例8: Initial_snapshot_and_subsequent_deltas_yield_full_snapshot_each_time
public void Initial_snapshot_and_subsequent_deltas_yield_full_snapshot_each_time()
{
var key = "EURUSD";
// arrange
var observations = new List<Update>();
_observableDictionary.Get(key)
.Only(DictionaryNotificationType.Values) // ignore meta notifications
.Select(dn => dn.Value) // select out the new value in the dictionary
.Subscribe(observations.Add);
// act
_serverUpdateStream.OnNext(new Either<FullUpdate, DeltaUpdate>(new FullUpdate(key) { { "bid", "1.234"}, { "ask", "1.334"}, { "valueDate", "2014-07-16"} }));
_serverUpdateStream.OnNext(new Either<FullUpdate, DeltaUpdate>(new DeltaUpdate(key) { { "bid", "1.233" }}));
_serverUpdateStream.OnNext(new Either<FullUpdate, DeltaUpdate>(new DeltaUpdate(key) { { "ask", "1.333" }}));
_serverUpdateStream.OnNext(new Either<FullUpdate, DeltaUpdate>(new DeltaUpdate(key) { { "bid", "1.231" }, { "ask", "1.331" }}));
// assert
observations.ForEach(update => Assert.AreEqual(4, update.Values.Count));
var first = observations.First();
var last = observations.Last();
Assert.AreEqual("1.234", first.Values["bid"]);
Assert.AreEqual("1.334", first.Values["ask"]);
Assert.AreEqual("1.231", last.Values["bid"]);
Assert.AreEqual("1.331", last.Values["ask"]);
}
示例9: SetUp
public void SetUp()
{
MigrationTestHelper.Clear();
_versionsFromDatabase = new List<long> { 0 };
var provider = new Mock<IDataProvider>();
provider.Setup(x => x.DatabaseKind).Returns(DatabaseKind.Oracle);
var database = new Mock<IDatabase>();
database.Setup(x => x.Provider).Returns(provider.Object);
_dataClient = new Mock<IDataClient>();
_dataClient.Setup(p => p.TableExists(VersionRepository.VERSION_TABLE_NAME)).Returns(true);
_dataClient.Setup(x => x.Database).Returns(database.Object);
_versionRepository = new Mock<IVersionRepository>();
_versionRepository.Setup(x => x.GetCurrentVersion()).Returns(() => _versionsFromDatabase.Last());
_versionRepository.Setup(x => x.GetAppliedMigrations()).Returns(() => _versionsFromDatabase);
_versionRepository.Setup(x => x.InsertVersion(It.IsAny<MigrationInfo>()))
.Callback<MigrationInfo>(m => _versionsFromDatabase.Add(m.Version));
_versionRepository.Setup(x => x.RemoveVersion(It.IsAny<MigrationInfo>()))
.Callback<MigrationInfo>(m => _versionsFromDatabase.Remove(m.Version));
_runner = new Runner(_dataClient.Object, Assembly.GetExecutingAssembly());
_runner.VersionRepository = _versionRepository.Object;
}
示例10: CreateRandomBets_GivenXBatchSize_ReturnsXInBatchSize
public void CreateRandomBets_GivenXBatchSize_ReturnsXInBatchSize(int numberOfBets, int maxBetsBatchSize)
{
// Given
var betsRecieved = new List<List<Bet>>();
var randomBetDataProvider = new RandomBetDataProvider(numberOfBets, maxBetsBatchSize);
randomBetDataProvider.BetsProvided += (sender, args) => { betsRecieved.Add(new List<Bet>(args.Bets)); };
randomBetDataProvider.BetsProviderFinished += (sender, args) =>
{
lock (_lockObject)
{
Monitor.Pulse(_lockObject);
}
};
// When
randomBetDataProvider.Start();
lock (_lockObject)
{
Monitor.Wait(_lockObject, TimeOut);
}
// Then
var lastBatch = betsRecieved.Last();
foreach (var betsRecievedBatch in betsRecieved)
{
if(betsRecievedBatch != lastBatch)
Assert.That(betsRecievedBatch.Count, Is.EqualTo(maxBetsBatchSize));
else
Assert.That(betsRecievedBatch.Count, Is.LessThanOrEqualTo(maxBetsBatchSize));
}
}
示例11: Register_roll
public void Register_roll(int[] rolls, int nFrames, int totalScore)
{
var sut = new Integration(new Frames(), new Scorer());
var results = new List<Game>();
sut.Result += results.Add;
rolls.ToList()
.ForEach(sut.Register_roll);
Assert.AreEqual(nFrames, results.Last().Frames.Count());
Assert.AreEqual(totalScore, results.Last().Score);
Assert.IsTrue(results[rolls.Length-1].Finished);
Assert.IsFalse(results[rolls.Length-2].Finished);
}
示例12: Add_Should_Save_And_Assigned_New_Ids_To_Multiple
public void Add_Should_Save_And_Assigned_New_Ids_To_Multiple(IRepository<Contact, string> repository)
{
IList<Contact> contacts = new List<Contact>
{
new Contact { Name = "Contact 1"},
new Contact { Name = "Contact 2"},
new Contact { Name = "Contact 3"},
};
repository.Add(contacts);
contacts.First().ContactId.ShouldNotBeEmpty();
contacts.Last().ContactId.ShouldNotBeEmpty();
contacts.First().ShouldNotBeSameAs(contacts.Last().ContactId);
var added = repository.GetAll();
added.Count().ShouldEqual(3);
}
示例13: can_shuffle
public void can_shuffle()
{
var ints = new List<int>();
1.UpTo(500, ints.Add);
ints.Shuffle();
(ints[0] == 1 && ints[1] == 2 && ints.Last() == 500).ShouldBeFalse();
ints.Distinct().Count().ShouldEqual(500);
}
示例14: TwoLegsReturnsOne
public void TwoLegsReturnsOne()
{
var traversal = new List<string>();
var startLeg = "AB";
var nextLeg = "BC";
_traverser.Invoke(startLeg, new Dictionary<string, int> { {nextLeg, 7}, { startLeg, 3 } }, ref traversal);
Assert.That(traversal.Count, Is.EqualTo(2));
Assert.That(traversal.First(), Is.EqualTo(startLeg));
Assert.That(traversal.Last(), Is.EqualTo(nextLeg));
}
示例15: ShouldNotFinishUntilAllMatchesPlayed
public void ShouldNotFinishUntilAllMatchesPlayed()
{
var leagueSeason = A.LeagueSeason.Build();
var fixtures = new List<Fixture>();
leagueSeason.ScheduleFixtures(f => fixtures.Add(f));
var allFixturesExceptLast = fixtures.Except(fixtures.Last().AsEnumerable()).ToList();
allFixturesExceptLast.ForEach(f => leagueSeason.ApplyResult(A.MatchResult.ForFixture(f).Build()));
Assert.That(leagueSeason.IsFinished, Is.False);
}