System.Collections.Generic.IEnumerable.First()

Here are the examples of the csharp api class System.Collections.Generic.IEnumerable.First() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: GridDomain
Source File: ExceptionExtensions.cs
public static Exception UnwrapSingle(this AggregateException aggregateException)
        {
            if (aggregateException == null)
                return null;

            if (aggregateException.InnerExceptions.Count > 1)
                return aggregateException;

            if(aggregateException.InnerExceptions.Count == 0)
            {
                //for cases when inner exceptions were lost due to hyperion serializer
                return aggregateException.InnerException ?? aggregateException;
            }
            //for cases when inner exceptions were lost due to hyperion serializer
            if (aggregateException.InnerException != null)
                return aggregateException.InnerException;

            return aggregateException.InnerExceptions.First().UnwrapSingle();
        }

2. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_find_all_specs()
        {
            _results.First().All.Length.ShouldEqual(29);
        }

3. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_find_succeeded_specs()
        {
            _results.First().Passed.Length.ShouldEqual(17);
        }

4. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_find_failed_specs()
        {
            _results.First().Failed.Length.ShouldEqual(4);
        }

5. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_find_ignored_specs()
        {
            _results.First().Ignored.Length.ShouldEqual(8);
        }

6. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_give_the_ignore_reason_for_unimplemented_specs()
        {
            _results.First().Ignored.Any(x => x.Message == "not implemented").ShouldBeTrue();
        }

7. Example

Project: ContinuousTests
Source File: MSpecReportParserTest.cs
[Test]
        public void Should_find_the_assembly_name()
        {
            _results.First().Assembly.ShouldEqual("C:\\Some\\Path\\Machine.Specifications.Example.Random.dll");
        }

8. Example

Project: FluentCache
Source File: ClosureTest.cs
public object GetFirstParameterValue<T>(T source, Expression<Action> expression)
        {
            var invocationCall = expression.Body as InvocationExpression;

            ExpressionAnalyzer analyzer = new ExpressionAnalyzer();

            object parameterValue;
            bool dontIgnore = analyzer.TryProcessParameter(source, invocationCall.Arguments.First(), checkForParameterDoNotCache: true, parameterValue:  out parameterValue);
            if (!dontIgnore)
                Assert.Fail("Should not have been ignore");

            return parameterValue;
        }

9. Example

Project: couchbase-net-client
Source File: BucketConfig.cs
public Node GetRandomNode()
        {
            Nodes.Shuffle();
            return Nodes.First();
        }

10. Example

Project: xRM-Portals-Community-Edition
Source File: StyleExtensions.cs
public bool TryGetTerminalNode(out Node terminalNode)
				{
					terminalNode = null;

					if (Children.Count != 1)
					{
						return false;
					}

					terminalNode = Children.First();

					return terminalNode.Key == TerminalNodeKey;
				}

11. Example

Project: Gister
Source File: AppliesGitHubCredentialsToFluentHttpRequest.cs
public static void ApplyCredentials(GitHubCredentials credentials, FluentHttpRequest request)
        {
            var map = new Dictionary<Type, CredentialVisitor>()
                          {
                              {typeof (AnonymousGitHubCredentials), new AnonymousGitHubCredentialsForFluentHttp()},
                              {typeof (GitHubUserCredentials), new GitHubUserCredentialsForFluentHttp()}
                          };

            var credentialApplier = (from item in map
                                     where item.Key == credentials.GetType()
                                     select item.Value).First();

            credentialApplier.Apply(request, credentials);
        }

12. Example

Project: Gister
Source File: GisterPackage.cs
private static GitHubCredentials GetGitHubCredentials()
        {
            var retrievers = new IRetrievesCredentials[]
                                 {
                                     new CachesGitHubCredentials(),
                                     new RetrievesUserEnteredCredentials()
                                 };

            var firstAppropriate = (from applier in retrievers
                                    where applier.IsAvailable()
                                    select applier).First();

            return firstAppropriate.Retrieve();
        }

13. Example

Project: Veil
Source File: SuperSimpleTemplateParserState.cs
public void AddNodeToCurrentBlock(SyntaxTreeNode node)
        {
            this.scopeStack.First().Block.Add(node);
        }

14. Example

Project: Veil
Source File: SuperSimpleTemplateParserState.cs
public Type CurrentTypeInScope()
        {
            return this.scopeStack.First().ModelType;
        }

15. Example

Project: CLAP
Source File: MultiParser.cs
private void HandleEmptyArguments(TargetResolver targetResolver)
        {
            if (Register.RegisteredEmptyHandler != null)
            {
                Register.RegisteredEmptyHandler();
            }
            else if (m_types.Length == 1)
            {
                var parser = new ParserRunner(m_types.First(), Register, HelpGenerator);

                var target = targetResolver == null ? null : targetResolver.Resolve(m_types[0]);

                parser.HandleEmptyArguments(target);
            }
        }

16. Example

Project: BotBuilder.Standard
Source File: Recognize.cs
public override DescribeAttribute ValueDescription(object value)
        {
            return new DescribeAttribute(((bool)value
                ? _field.Form.Configuration.Yes
                : _field.Form.Configuration.No).First());
        }

17. Example

Project: BotBuilder.Standard
Source File: Steps.cs
public async Task<StepResult> ProcessAsync(IDialogContext context, T state, FormState form, IMessageActivity input, IEnumerable<TermMatch> matches)
        {
            NextStep next;
            form.Next = null;
            var val = matches.First().Value;
            if (val == null)
            {
                next = new NextStep();
            }
            else
            {
                next = new NextStep(new string[] { (string)val });
            }
            return new StepResult(true, next, feedback: null, prompt: null);
        }

18. Example

Project: CypherCore
Source File: TaskScheduler.cs
public Task First()
        {
            return container.First();
        }

19. Example

Project: CypherCore
Source File: Transport.cs
void UnloadStaticPassengers()
        {
            while (!_staticPassengers.Empty())
            {
                WorldObject obj = _staticPassengers.First();
                obj.AddObjectToRemoveList();   // also removes from _staticPassengers
            }
        }

20. Example

Project: CypherCore
Source File: TransportManager.cs
TransportAnimationRecord GetAnimNode(uint time)
        {
            if (Path.Empty())
                return null;

            foreach (var pair in Path)
                if (time >= pair.Key)
                    return pair.Value;

            return Path.First().Value;
        }

21. Example

Project: CypherCore
Source File: TransportManager.cs
Quaternion GetAnimRotation(uint time)
        {
            if (Rotations.Empty())
                return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);

            TransportRotationRecord rot = Rotations.First().Value;
            foreach (var pair in Rotations)
            {
                if (time >= pair.Key)
                {
                    rot = pair.Value;
                    break;
                }
            }

            return new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
        }

22. Example

Project: CypherCore
Source File: EyeOfEternity.cs
public override ObjectGuid GetGuidData(uint data)
            {
                switch (data)
                {
                    case InstanceData64.Trigger:
                        return vortexTriggers.First();
                    case InstanceData64.Malygos:
                        return malygosGUID;
                    case InstanceData64.Platform:
                        return platformGUID;
                    case InstanceData64.AlexstraszaBunnyGUID:
                        return alexstraszaBunnyGUID;
                    case InstanceData64.HeartOfMagicGUID:
                        return heartOfMagicGUID;
                    case InstanceData64.FocusingIrisGUID:
                        return irisGUID;
                    case InstanceData64.GiftBoxBunnyGUID:
                        return giftBoxBunnyGUID;
                }

                return ObjectGuid.Empty;
            }

23. Example

Project: CypherCore
Source File: Generic.cs
void OnPeriodic(AuraEffect aurEff)
        {
            if (_applyTimes.Empty())
                return;

            // pop stack if it expired for us
            if (_applyTimes.First() + GetMaxDuration() < Time.GetMSTime())
                ModStackAmount(-1, AuraRemoveMode.Expire);
        }

24. Example

Project: CypherCore
Source File: Paladin.cs
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
        {
            PreventDefaultAction();

            HealInfo healInfo = eventInfo.GetHealInfo();
            if (healInfo == null || healInfo.GetHeal() == 0)
                return;

            uint heal = MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount());

            var auras = GetCaster().GetSingleCastAuras();
            foreach (var eff in auras)
            {
                if (eff.GetId() == SpellIds.BeaconOfLight)
                {
                    List<AuraApplication> applications = eff.GetApplicationList();
                    if (!applications.Empty())
                        eventInfo.GetActor().CastCustomSpell(SpellIds.BeaconOfLightHeal, SpellValueMod.BasePoint0, (int)heal, applications.First().GetTarget(), true);
                    return;
                }
            }
        }

25. Example

Project: CypherCore
Source File: Priest.cs
public override void OnInitialize()
            {
                Unit caster = at.GetCaster();
                if (caster)
                {
                    List<AreaTrigger> areaTriggers = caster.GetAreaTriggers(SpellIds.AngelicFeatherAreatrigger);

                    if (areaTriggers.Count >= 3)
                        areaTriggers.First().SetDuration(0);
                }
            }

26. Example

Project: DalSoft.RestClient
Source File: RestClientTests.cs
[Test]
        public async Task Get_NestedCommentsFromUser_GetsCommentCorrectly()
        {
            dynamic client = new RestClient(BaseUri);

            List<Comment> comment = await client.users(2).Comments.Get();

            Assert.That(comment.First().postId, Is.EqualTo(1));
        }

27. Example

Project: DalSoft.RestClient
Source File: DefaultJsonHandlerTests.cs
[Test]
        public async Task Send_DoNotSetAcceptHeader_SetsAcceptHeaderToJson()
        {
            HttpRequestMessage actualRequest = null;
            var httpClientWrapper = new HttpClientWrapper
            (
                new Config(new UnitTestHandler(request => actualRequest = request))
            );

            await httpClientWrapper.Send(HttpMethod.Post, new Uri(BaseUrl), requestHeaders:null, content:new {});

            Assert.That(actualRequest.Headers.Accept.First().MediaType, Is.EqualTo(Config.JsonMediaType));
        }

28. Example

Project: DalSoft.RestClient
Source File: DefaultJsonHandlerTests.cs
[Test]
        public async Task Send_EmptyAcceptHeader_SetsAcceptHeaderToJson()
        {
            HttpRequestMessage actualRequest = null;
            var httpClientWrapper = new HttpClientWrapper
            (
                new Config(new UnitTestHandler(request => actualRequest = request))
            );

            await httpClientWrapper.Send(HttpMethod.Post, new Uri(BaseUrl), requestHeaders:new Dictionary<string, string>(), content:new {});

            Assert.That(actualRequest.Headers.Accept.First().MediaType, Is.EqualTo(Config.JsonMediaType));
        }

29. Example

Project: DalSoft.RestClient
Source File: DefaultJsonHandlerTests.cs
[Test]
        public async Task Send_PassingAcceptHeader_IsTheOnlyHeaderSet()
        {
            HttpRequestMessage actualRequest = null;
            var httpClientWrapper = new HttpClientWrapper
            (
                new Config(new UnitTestHandler(request => actualRequest = request))
            );

            await httpClientWrapper.Send(HttpMethod.Post, new Uri(BaseUrl), new Dictionary<string, string> { {"Accept", "application/custom+accept"} }, new { });

            Assert.That(actualRequest.Headers.Accept.Count, Is.EqualTo(1));
            Assert.That(actualRequest.Headers.Accept.First().MediaType, Is.EqualTo("application/custom+accept"));
        }

30. Example

Project: DalSoft.RestClient
Source File: DefaultJsonHandlerTests.cs
[Test]
        public async Task Send_PassingAcceptHeaderUsingDefaultHeaders_IsTheOnlyHeaderSet()
        {
            HttpRequestMessage actualRequest = null;
            var httpClientWrapper = new HttpClientWrapper
            (
                new Dictionary<string, string> { { "Accept", "application/custom+accept" } },
                new Config(new UnitTestHandler(request => actualRequest = request))
            );

            await httpClientWrapper.Send(HttpMethod.Post, new Uri(BaseUrl), null, new { });

            Assert.That(actualRequest.Headers.Accept.Count, Is.EqualTo(1));
            Assert.That(actualRequest.Headers.Accept.First().MediaType, Is.EqualTo("application/custom+accept"));
        }

31. Example

Project: nextra
Source File: PathPatternMatcherBehavior.cs
[Test, ExpectedException(typeof(ArgumentNullException))]
        public void IsMatch_ShouldFailForNullPath()
        {
            _pathPatternMatcher.IsMatch(null, _exactCollection.First());
        }

32. Example

Project: mycouch
Source File: ShowTests.cs
[MyFact(TestScenarios.ShowsContext)]
        public void When_querying_show_that_transforms_doc_to_xml_It_should_return_xml()
        {
            var artist = ArtistsById.First();
            var query = new QueryShowRequest(ClientTestData.Shows.ArtistsXmlShowId)
                .Configure(c => c.DocId(artist.ArtistId)
                .Accepts(HttpContentTypes.Xml)
                );

            var response = SUT.ShowAsync(query).Result;

            response.Should().BeGetOfXml();
            var transformedArtist = XElement.Parse(response.Content);
            transformedArtist.Value.Should().Be(artist.Name);
        }

33. Example

Project: mcs-ICodeCompiler
Source File: ecore.cs
public override string GetSignatureForError ()
		{
			if (best_candidate != null)
				return best_candidate.GetSignatureForError ();

			return Methods.First ().GetSignatureForError ();
		}

34. Example

Project: csharp-driver
Source File: SessionExecuteAsyncTests.cs
[Test]
        public void SessionExecuteAsyncSyntaxErrorQuery()
        {
            //Execute an invalid query 
            var task = Session.ExecuteAsync(new SimpleStatement("SELECT WILL FAIL"));
            task.ContinueWith(t =>
            {
                Assert.NotNull(t.Exception);
            }, TaskContinuationOptions.OnlyOnFaulted);

            task.ContinueWith(t =>
            {
                Assert.Fail("Task should not have continued");
            }, TaskContinuationOptions.OnlyOnRanToCompletion);

            Exception exThrown = null;
            try
            {
                task.Wait();
            }
            catch (Exception ex)
            {
                exThrown = ex;
            }
            Assert.NotNull(exThrown);
            Assert.IsInstanceOf<AggregateException>(exThrown);
            Assert.IsInstanceOf<SyntaxError>(((AggregateException)exThrown).InnerExceptions.First());
        }

35. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToList()
        {
            Tuple<Table<EntityWithListType>, List<EntityWithListType>> tupleListType = EntityWithListType.SetupDefaultTable(Session);
            Table<EntityWithListType> table = tupleListType.Item1;
            List<EntityWithListType> expectedEntities = tupleListType.Item2;

            List<int> listToAdd = new List<int> { -1, 0, 5, 6 };
            EntityWithListType singleEntity = expectedEntities.First();
            EntityWithListType expectedEntity = singleEntity.Clone();
            expectedEntity.ListType.AddRange(listToAdd);
            // Append the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.Append(listToAdd) }).Update().Execute();
            // Validate final state of the data
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            Assert.AreNotEqual(expectedEntity.ListType, singleEntity.ListType);
            expectedEntity.AssertEquals(entityList[0]);
        }

36. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToList_StartsOutEmpty()
        {
            Tuple<Table<EntityWithListType>, List<EntityWithListType>> tupleListType = EntityWithListType.SetupDefaultTable(_session);
            Table<EntityWithListType> table = tupleListType.Item1;
            List<EntityWithListType> expectedEntities = tupleListType.Item2;

            // overwrite the row we're querying with empty list
            EntityWithListType singleEntity = expectedEntities.First();
            singleEntity.ListType.Clear();
            table.Insert(singleEntity).Execute();
            EntityWithListType expectedEntity = singleEntity.Clone();

            List<int> listToAdd = new List<int> { -1, 0, 5, 6 };
            expectedEntity.ListType.AddRange(listToAdd);
            // Append the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.Append(listToAdd) }).Update().Execute();
            // Validate final state of the data
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            Assert.AreNotEqual(expectedEntity.ListType, singleEntity.ListType);
            expectedEntity.AssertEquals(entityList[0]);
        }

37. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToList_AppendEmptyList()
        {
            Tuple<Table<EntityWithListType>, List<EntityWithListType>> tupleListType = EntityWithListType.SetupDefaultTable(_session);
            Table<EntityWithListType> table = tupleListType.Item1;
            List<EntityWithListType> expectedEntities = tupleListType.Item2;

            List<int> listToAdd = new List<int> ();
            EntityWithListType singleEntity = expectedEntities.First();
            EntityWithListType expectedEntity = singleEntity.Clone();
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.Append(listToAdd) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            expectedEntity.AssertEquals(entityList[0]);
        }

38. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToDictionary()
        {
            Tuple<Table<EntityWithD/n ..... /n //View Source file for more details /n }

39. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToDictionary_EmptyDictionary()
        {
            Tuple<Table<EntityWithDictionaryType>, List<EntityWithDictionaryType>> tupleDictionaryType = EntityWithDictionaryType.SetupDefaultTable(_session);
            Table<EntityWithDictionaryType> table = tupleDictionaryType.Item1;
            List<EntityWithDictionaryType> expectedEntities = tupleDictionaryType.Item2;

            Dictionary<string, string> dictToAdd = new Dictionary<string, string>() {};
            EntityWithDictionaryType singleEntity = expectedEntities.First();
            EntityWithDictionaryType expectedEntity = singleEntity.Clone();
            foreach (var keyValPair in dictToAdd)
                expectedEntity.DictionaryType.Add(keyValPair.Key, keyValPair.Value);

            // Append the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithDictionaryType { DictionaryType = CqlOperator.Append(dictToAdd) }).Update().Execute();
            // Validate the final state of the data
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            expectedEntity.AssertEquals(entityList[0]);
        }

40. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToDictionary_DuplicateKey()
        {
            Tuple<Table<EntityWithDictionaryType>, List<EntityWithDictionaryType>> tupleDictionaryType = EntityWithDictionaryType.SetupDefaultTable(_session);
            Table<EntityWithDictionaryType> table = tupleDictionaryType.Item1;
            List<EntityWithDictionaryType> expectedEntities = tupleDictionaryType.Item2;

            EntityWithDictionaryType singleEntity = expectedEntities.First();
            EntityWithDictionaryType expectedEntity = singleEntity.Clone();
            Assert.AreEqual(expectedEntity.DictionaryType, singleEntity.DictionaryType);

            // Append the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithDictionaryType { DictionaryType = CqlOperator.Append(singleEntity.DictionaryType) }).Update().Execute();

            // Validate the final state of the data
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            expectedEntity.AssertEquals(entityList[0]);
        }

41. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToDictionary_DuplicateAndNonDuplicateKey()
        {
            T/n ..... /n //View Source file for more details /n }

42. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToList_TableWithAllCollectionTypes()
        {
            Tuple<Table<EntityWithAllCollectionTypes>, List<EntityWithAllCollectionTypes>> tupleAllCollectionTypes = EntityWithAllCollectionTypes.SetupDefaultTable(_session);
            Table<EntityWithAllCollectionTypes> table = tupleAllCollectionTypes.Item1;
            List<EntityWithAllCollectionTypes> expectedEntities = tupleAllCollectionTypes.Item2;

            EntityWithAllCollectionTypes singleEntity = expectedEntities.First();
            var toAppend = new List<int> { 5, 6 };
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithAllCollectionTypes { ListType = CqlOperator.Append(toAppend) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            CollectionAssert.AreEqual(singleEntity.ListType.Concat(toAppend), entityList.First().ListType);
        }

43. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToArray_TableWithAllCollectionTypes()
        {
            Tuple<Table<EntityWithAllCollectionTypes>, List<EntityWithAllCollectionTypes>> tupleAllCollectionTypes = EntityWithAllCollectionTypes.SetupDefaultTable(_session);
            Table<EntityWithAllCollectionTypes> table = tupleAllCollectionTypes.Item1;
            List<EntityWithAllCollectionTypes> expectedEntities = tupleAllCollectionTypes.Item2;

            EntityWithAllCollectionTypes singleEntity = expectedEntities.First();
            var toAppend = new string[] { "tag1", "tag2", "tag3" };
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithAllCollectionTypes { ArrayType = CqlOperator.Append(toAppend) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            CollectionAssert.AreEqual(singleEntity.ArrayType.Concat(toAppend), entityList.First().ArrayType);
        }

44. Example

Project: csharp-driver
Source File: Append.cs
[Test]
        public void Append_ToDictionary_TableWithAllCollectionTypes()
        {
            Tuple<Table<EntityWithAllCollectionTypes>, List<EntityWithAllCollectionTypes>> tupleAllCollectionTypes = EntityWithAllCollectionTypes.SetupDefaultTable(_session);
            Table<EntityWithAllCollectionTypes> table = tupleAllCollectionTypes.Item1;
            List<EntityWithAllCollectionTypes> expectedEntities = tupleAllCollectionTypes.Item2;

            EntityWithAllCollectionTypes singleEntity = expectedEntities.First();
            EntityWithAllCollectionTypes expectedEntity = singleEntity.Clone();
            expectedEntity.DictionaryType.Add("key1","val1");
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithAllCollectionTypes { DictionaryType = CqlOperator.Append(expectedEntity.DictionaryType) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            CollectionAssert.AreEqual(expectedEntity.ArrayType, singleEntity.ArrayType);
            entityList.First().AssertEquals(expectedEntity);
        }

45. Example

Project: csharp-driver
Source File: Prepend.cs
[Test]
        public void Prepend_ToList_PrependEmptyList()
        {
            Tuple<Table<EntityWithListType>, List<EntityWithListType>> tupleListType = EntityWithListType.SetupDefaultTable(_session);
            Table<EntityWithListType> table = tupleListType.Item1;
            List<EntityWithListType> expectedEntities = tupleListType.Item2;

            List<int> listToAdd = new List<int> ();
            EntityWithListType singleEntity = expectedEntities.First();
            EntityWithListType expectedEntity = singleEntity.Clone();
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.Prepend(listToAdd) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            expectedEntity.AssertEquals(entityList[0]);
        }

46. Example

Project: csharp-driver
Source File: SubstractAssign.cs
[Test]
        public void SubtractAssign_FromList_ValNotInList()
        {
            var tupleListType = EntityWithListType.SetupDefaultTable(Session);
            var table = tupleListType.Item1;
            var expectedEntities = tupleListType.Item2;
            var singleEntity = expectedEntities.First();
            var valsToDelete = new List<int>() { 9999 };

            // make sure this value is not in the list
            Assert.IsFalse(singleEntity.ListType.Contains(valsToDelete.First()));

            // SubstractAssign the values
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.SubstractAssign(valsToDelete) }).Update().Execute();

            // Validate final state of the data
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            singleEntity.AssertEquals(entityList[0]);
        }

47. Example

Project: csharp-driver
Source File: First.cs
[Test]
        public void First_ExecuteAsync()
        {
            var expectedMovie = _movieList.First();

            var actualMovie = _movieTable.First(m => m.Title == expectedMovie.Title && m.MovieMaker == expectedMovie.MovieMaker).ExecuteAsync().Result;
            Movie.AssertEquals(expectedMovie, actualMovie);
        }

48. Example

Project: csharp-driver
Source File: First.cs
[Test]
        public void First_ExecuteSync()
        {
            var expectedMovie = _movieList.First();

            var actualMovie = _movieTable.First(m => m.Title == expectedMovie.Title && m.MovieMaker == expectedMovie.MovieMaker).Execute();
            Movie.AssertEquals(expectedMovie, actualMovie);
        }

49. Example

Project: csharp-driver
Source File: FirstOrDefault.cs
[Test]
        public void LinqFirstOrDefault_Sync()
        {
            var expectedMovie = _movieList.First();

            // Test
            var first =
                _movieTable.FirstOrDefault(
                    m => m.Director == expectedMovie.Director && m.Title == expectedMovie.Title && m.MovieMaker == expectedMovie.MovieMaker).Execute();
            Assert.IsNotNull(first);
            Assert.AreEqual(expectedMovie.MovieMaker, first.MovieMaker);
        }

50. Example

Project: csharp-driver
Source File: Where.cs
[Test]
        public void LinqWhere_ExecuteAsync()
        {
            var expectedMovie = _movieList.First();

            // test
            var taskSelect = _movieTable.Where(m => m.Title == expectedMovie.Title && m.MovieMaker == expectedMovie.MovieMaker).ExecuteAsync();
            List<Movie> movies = taskSelect.Result.ToList();
            Assert.AreEqual(1, movies.Count);

            var actualMovie = movies.First();
            Movie.AssertEquals(expectedMovie, actualMovie);
        }