当前位置: 首页>>代码示例>>C#>>正文


C# List.First方法代码示例

本文整理汇总了C#中NUnit.Framework.List.First方法的典型用法代码示例。如果您正苦于以下问题:C# List.First方法的具体用法?C# List.First怎么用?C# List.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NUnit.Framework.List的用法示例。


在下文中一共展示了List.First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestParameterSerialization

 public void TestParameterSerialization()
 {
     var decoder = new PackedDecoder();
     var p = new List<Parameter>();
     decoder.WriteParameters(p);
     Assert.AreNotEqual(0, p.Count);
     var c1 = p.Count;
     decoder.WriteParameters(p);
     Assert.AreEqual(c1, p.Count);
     decoder.ColorBPP = 4;
     var cf = new ColorFormat(12, 5, 6, 4, 1, 3, 18, 1);
     decoder.ColorFormat = cf;
     ((IPictureDecoderController)decoder).Width = 13;
     ((IPictureDecoderController)decoder).Height = 21;
     decoder.WriteParameters(p);
     Assert.AreEqual(1.ToString(), p.First(z => z.Name == "ppbyp").Value);
     Assert.AreEqual(cf.ToString(), p.First(z => z.Name == "ColorFormat").Value);
     Assert.AreEqual("13", p.First(z => z.Name == "Width").Value);
     Assert.AreEqual("21", p.First(z => z.Name == "Height").Value);
     var d2 = new PackedDecoder();
     d2.ReadParameters(p);
     Assert.AreEqual(4, d2.ColorBPP);
     Assert.AreEqual(cf, d2.ColorFormat);
     Assert.AreEqual(13, ((IPictureDecoderController)decoder).Width);
     Assert.AreEqual(21, ((IPictureDecoderController)decoder).Height);
 }
开发者ID:kael-ip,项目名称:rippix,代码行数:26,代码来源:PackedDecoder.cs

示例2: Send_Given30TosAnd30Bccs_SendTwoBatches

        public void Send_Given30TosAnd30Bccs_SendTwoBatches()
        {
            var senderMock = new Mock<IEmailSender>();
            var service = new Portal.EmailService.EmailService(senderMock.Object);

            var tos = new List<string>();
            var bccs = new List<string>();
            const string from = "[email protected]";
            const string subject = "Test Email";
            const string body = "<div>Hallo test</div>";

            for (var i = 0; i < 30; i++)
                tos.Add(string.Format("MyMail{0}@test.test", i));
            for (var i = 0; i < 30; i++)
                bccs.Add(string.Format("MyBccMail{0}@test.test", i));

            IList<SendEmailRequest> request = new List<SendEmailRequest>();

            senderMock.SetupGet(s => s.MaxRecipientPerBatch).Returns(50);
            senderMock.Setup(s => s.Send(It.IsAny<SendEmailRequest>())).Callback<SendEmailRequest>(request.Add);

            service.Send(from, tos, bccs, subject, body);

            senderMock.Verify(s => s.Send(It.IsAny<SendEmailRequest>()), Times.Exactly(2));

            Assert.That(request.Count, Is.EqualTo(2));
            Assert.That(request.First().Destination.ToAddresses.Count, Is.EqualTo(30));
            Assert.That(request.First().Destination.BccAddresses.Count, Is.EqualTo(20));
            Assert.That(request.Skip(1).First().Destination.ToAddresses.Count, Is.EqualTo(0));
            Assert.That(request.Skip(1).First().Destination.BccAddresses.Count, Is.EqualTo(10));
        }
开发者ID:CHAOS-Community,项目名称:Portal,代码行数:31,代码来源:AWSEmailServiceTest.cs

示例3: Given_selected_responsibilities_When_GetViewModel_Then_those_responsibilities_are_marked_as_selected

        public void Given_selected_responsibilities_When_GetViewModel_Then_those_responsibilities_are_marked_as_selected()
        {
            // Given
            const int companyId = 12345;
            var templates = new List<StatutoryResponsibilityTemplateDto>
                            {
                                new StatutoryResponsibilityTemplateDto() { Id = 123L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"}},
                                new StatutoryResponsibilityTemplateDto() { Id = 456L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"} },
                                new StatutoryResponsibilityTemplateDto() { Id = 789L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"} }
                            };

            _statutoryResponsibilityTemplateService
               .Setup(x => x.GetStatutoryResponsibilityTemplates())
               .Returns(templates);

            // When
            var result = GetTarget()
                .WithCompanyId(companyId)
                .WithSelectedResponsibilityTemplates(new [] { templates.First().Id })
                .GetViewModel();

            // Then
            Assert.IsTrue(result.Responsibilities.Single(x => x.Id == templates.First().Id ).IsSelected);
            Assert.IsFalse(result.Responsibilities.Single(x => x.Id == templates.ElementAt(1).Id ).IsSelected);
            Assert.IsFalse(result.Responsibilities.Single(x => x.Id == templates.ElementAt(2).Id).IsSelected);
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:26,代码来源:SelectResponsibilitiesViewModelFactoryTests.cs

示例4: CommaDelimited

        public void CommaDelimited() {

            const string content = @"Name,WebSite,Created
Google|,http://www.google.com|,9/4/98
Apple|,http://www.apple.com|,4/1/1976
Microsoft|,http://www.microsoft.com|,4/4/1975";

            var fileName = Path.GetTempFileName();
            File.WriteAllText(fileName, content);

            JunkResponse response;
            var request = new JunkRequest(fileName, "default.xml");
            using (var scope = new AutofacJunkBootstrapper(request)) {
                var importer = scope.Resolve<JunkImporter>();
                response = importer.Import();
            }

            var companies = new List<Company>();

            using (var cn = new SqlConnection(ConnectionString)) {
                companies.AddRange(cn.Query<Company>("SELECT Name,Website,Created FROM " + response.TableName + ";"));
            }

            Assert.AreEqual(3, companies.Count);

            var google = companies.First(c => c.Name == "Google|");
            var apple = companies.First(c => c.Name == "Apple|");

            Assert.AreEqual("http://www.google.com|", google.WebSite);
            Assert.AreEqual(Convert.ToDateTime("4/1/1976"), apple.Created);

        }
开发者ID:modulexcite,项目名称:JunkDrawer,代码行数:32,代码来源:SqlServerIntegration.cs

示例5: Succeed

        public static void Succeed(params Action[] assertions)
        {
            var errors = new List<Exception>();

            foreach (var assertion in assertions)
                try
                {
                    assertion();
                }
                catch (Exception ex)
                {
                    errors.Add(ex);
                }

            if (errors.Any())
            {
                var ex = new AssertionException(
                    string.Join(Environment.NewLine, errors.Select(e => e.Message)),
                    errors.First());

                // Use stack trace from the first exception to ensure first failed Assert is one click away
                ReplaceStackTrace(ex, errors.First().StackTrace);

                throw ex;
            }
        }
开发者ID:peterbartels,项目名称:Informedica.GenPres.System,代码行数:26,代码来源:AssertAll.cs

示例6: TestBindModel

        public void TestBindModel()
        {
            //{element}.{key} type의 from 데이터를 ICollection<KeyValue<String,String>으로 변환
            var ctx = new ControllerContext();
            var mockHc = new Mock<HttpContextBase>();
            var mockHrc = new Mock<HttpRequestBase>();
            ctx.RequestContext = new RequestContext();
            mockHc.Setup(m => m.Request).Returns(mockHrc.Object);
            ctx.RequestContext.HttpContext = mockHc.Object;
            var nvc = new NameValueCollection();
            nvc.Add("Options.US Shoe Size (Men's)", "10.5");
            mockHrc.Setup(m => m.Form).Returns(nvc);

            var binder = new DynamicDictionaryObjectModelBinder();
            var mbc = new ModelBindingContext();
            var mmc = new Mock<ModelMetadata>();
            mmc.Setup(p => p.Model).Returns(new DynamicDictionaryObject());
            mbc.ModelMetadata = mmc.Object;

            dynamic output = binder.BindModel(ctx, mbc);

            ICollection<KeyValue> actual = output.Options;

            IList<KeyValue> expected = new List<KeyValue>();
            expected.Add(new KeyValue() { Key = "US Shoe Size (Men's)", Value = "10.5" });

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected.First().Key, actual.First().Key);
            Assert.AreEqual(expected.First().Value, actual.First().Value);
        }
开发者ID:tomochandv,项目名称:Test,代码行数:30,代码来源:DynamicDicionaryObjectModelBinderTest.cs

示例7: 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);
        }
开发者ID:nicholassuter,项目名称:Belote,代码行数:15,代码来源:CartesExtensionsTests.cs

示例8: SessionGracefullyWaitsPendingOperations

        public void SessionGracefullyWaitsPendingOperations()
        {
            Logger.Info("Starting SessionGracefullyWaitsPendingOperations");
            var localCluster = Cluster.Builder().AddContactPoint(IpPrefix + "1").Build();
            try
            {
                var localSession = (Session)localCluster.Connect();

                //Create more async operations that can be finished
                var taskList = new List<Task>();
                for (var i = 0; i < 1000; i++)
                {
                    taskList.Add(localSession.ExecuteAsync(new SimpleStatement("SELECT * FROM system.schema_columns")));
                }
                //Most task should be pending
                Assert.True(taskList.Any(t => t.Status == TaskStatus.WaitingForActivation), "Most task should be pending");
                //Wait for finish
                Assert.True(localSession.WaitForAllPendingActions(60000), "All handles have received signal");

                Assert.False(taskList.Any(t => t.Status == TaskStatus.WaitingForActivation), "All task should be completed (not pending)");

                if (taskList.Any(t => t.Status == TaskStatus.Faulted))
                {
                    throw taskList.First(t => t.Status == TaskStatus.Faulted).Exception;
                }
                Assert.True(taskList.All(t => t.Status == TaskStatus.RanToCompletion), "All task should be completed");

                localSession.Dispose();
            }
            finally
            {
                localCluster.Shutdown(1000);
            }
        }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:34,代码来源:SessionTests.cs

示例9: 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));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:26,代码来源:ResistorTest.cs

示例10: Should_activate_upstream_deps_first

        public void Should_activate_upstream_deps_first()
        {
            var defaultsOrder = new List<Feature>();

            var dependingFeature = new DependsOnOne_Feature
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };
            var feature = new MyFeature1
            {
                OnDefaults = f => defaultsOrder.Add(f)
            };

            var settings = new SettingsHolder();
            var featureSettings = new FeatureActivator(settings);

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);

            settings.EnableFeatureByDefault<MyFeature1>();

            featureSettings.SetupFeatures(new FeatureConfigurationContext(null));

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<MyFeature1>(defaultsOrder.First(), "Upstream deps should be activated first");
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:27,代码来源:FeatureDefaultsTests.cs

示例11: Eh_Um_Par

        public void Eh_Um_Par()
        {
            var cartas = new List<Carta>
            {
                new Carta(NumeroCarta.C1, 'D'),
                new Carta(NumeroCarta.CJ, 'D'),
                new Carta(NumeroCarta.CQ, 'S'),
                new Carta(NumeroCarta.C9, 'H'),
                new Carta(NumeroCarta.CQ, 'C')
            };

            Carta primeira = cartas.First();
            bool tempar = false;
            for (int index = 0; index < cartas.Count; index++)
            {
                for (int i = index + 1; i < cartas.Count; i++)
                {
                    if (cartas[index].Numero == cartas[i].Numero)
                    {
                        tempar = true;
                        break;
                    }
                }

            }
            Assert.AreEqual(true, tempar);
        }
开发者ID:fortesinformatica,项目名称:I-Dojo-Fortes,代码行数:27,代码来源:Jogo_Teste.cs

示例12: 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"]);
        }
开发者ID:dunkymole,项目名称:adaptive-reactive,代码行数:28,代码来源:Deltas.cs

示例13: 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()));
        }
开发者ID:kylezimmerman,项目名称:prog3050,代码行数:29,代码来源:PlatformsControllerTests.cs

示例14: Should_activate_upstream_dependencies_first

        public void Should_activate_upstream_dependencies_first()
        {
            var order = new List<Feature>();

            var dependingFeature = new NamespaceB.MyFeature
            {
                OnActivation = f => order.Add(f)
            };
            var feature = new NamespaceA.MyFeature
            {
                OnActivation = f => order.Add(f)
            };

            var settings = new SettingsHolder();
            var featureSettings = new FeatureActivator(settings);

            featureSettings.Add(dependingFeature);
            featureSettings.Add(feature);

            settings.EnableFeatureByDefault<NamespaceA.MyFeature>();

            featureSettings.SetupFeatures(null, null);

            Assert.True(dependingFeature.IsActive);

            Assert.IsInstanceOf<NamespaceA.MyFeature>(order.First(), "Upstream dependencies should be activated first");
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:27,代码来源:FeatureDifferingOnlyByNamespaceTests.cs

示例15: 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;
            }
        }         
开发者ID:tystol,项目名称:ServiceStack,代码行数:31,代码来源:AsyncProgressTests.cs


注:本文中的NUnit.Framework.List.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。