public void Constructor_should_create_a_valid_instance() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, Enumerable.Empty<BsonDocument>(), BsonDocumentSerializer.Instance, _messageEncoderSettings); subject.CollectionNamespace.Should().Be(_collectionNamespace); subject.Pipeline.Should().BeEmpty(); subject.ResultSerializer.Should().BeSameAs(BsonDocumentSerializer.Instance); subject.MessageEncoderSettings.Should().BeEquivalentTo(_messageEncoderSettings); }
public void AllowDiskUse_should_have_the_correct_value() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, Enumerable.Empty<BsonDocument>(), BsonDocumentSerializer.Instance, _messageEncoderSettings); subject.AllowDiskUse.Should().Be(null); subject.AllowDiskUse = true; subject.AllowDiskUse.Should().Be(true); }
public void Constructor_should_create_a_valid_instance() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); subject.CollectionNamespace.Should().Be(_collectionNamespace); subject.Pipeline.Should().Equal(__pipeline); subject.ResultSerializer.Should().BeSameAs(__resultSerializer); subject.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings); subject.AllowDiskUse.Should().NotHaveValue(); subject.BatchSize.Should().NotHaveValue(); subject.Collation.Should().BeNull(); subject.MaxTime.Should().NotHaveValue(); subject.ReadConcern.IsServerDefault.Should().BeTrue(); subject.UseCursor.Should().NotHaveValue(); }
protected override void Given() { Require.MinimumServerVersion("2.4.0"); _subject = new AggregateOperation <BsonDocument>( CollectionNamespace, new[] { BsonDocument.Parse("{$match: {x: { $gt: 10}}}") }, BsonDocumentSerializer.Instance, MessageEncoderSettings); Insert(new[] { BsonDocument.Parse("{_id: 1, x: 1}"), BsonDocument.Parse("{_id: 2, x: 2}"), BsonDocument.Parse("{_id: 3, x: 3}"), BsonDocument.Parse("{_id: 4, x: 4}"), BsonDocument.Parse("{_id: 5, x: 5}"), BsonDocument.Parse("{_id: 6, x: 6}"), }); }
private bool Zero(AggregateOperation operation) { switch (operation) { case AggregateOperation.And: while (true) { return(true); } case AggregateOperation.Or: case AggregateOperation.Xor: while (true) { return(false); } default: throw new ArgumentOutOfRangeException(nameof(operation)); } }
private void ScaleVehicles(AggregateOperation operation, double factor) { double x; double y; switch (operation) { case AggregateOperation.Average: x = _myAvgX; y = _myAvgY; break; case AggregateOperation.Min: x = _myMinX; y = _myMinY; break; case AggregateOperation.Max: x = _myMaxX; y = _myMaxY; break; default: x = _world.Width / 2D; y = _world.Height / 2D; break; } var move = new Move { Action = ActionType.Scale, Factor = factor, X = x, Y = y }; ActionQueue.Enqueue(move); }
public void DeleteCacheEntryIfAny(AggregateConfiguration configuration, AggregateOperation operation) { var table = GetLatestResultsTableUnsafe(configuration, operation); if (table != null) { using (var con = _server.GetConnection()) { con.Open(); //drop the data _database.ExpectTable(table.GetRuntimeName()).Drop(); //delete the record! int deletedRows = DatabaseCommandHelper.GetCommand("DELETE FROM CachedAggregateConfigurationResults WHERE AggregateConfiguration_ID = " + configuration.ID + " AND Operation = '" + operation + "'", con).ExecuteNonQuery(); if (deletedRows != 1) { throw new Exception("Expected exactly 1 record in CachedAggregateConfigurationResults to be deleted when erasing its record of operation " + operation + " but there were " + deletedRows + " affected records"); } } } }
public void BatchSize_should_have_the_correct_value() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, Enumerable.Empty<BsonDocument>(), BsonDocumentSerializer.Instance, _messageEncoderSettings); subject.BatchSize.Should().Be(null); subject.BatchSize = 23; subject.BatchSize.Should().Be(23); }
public void Executing_with_matching_documents_using_all_options( [Values(false, true)] bool async) { var pipeline = BsonDocument.Parse("{$match: {_id: { $gt: 3}}}"); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, new[] { pipeline }, BsonDocumentSerializer.Instance, _messageEncoderSettings) { AllowDiskUse = true, BatchSize = 2, MaxTime = TimeSpan.FromSeconds(20) }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().HaveCount(2); }
public IHasFullyQualifiedNameToo GetLatestResultsTableUnsafe(AggregateConfiguration configuration, AggregateOperation operation) { using (var con = _server.GetConnection()) { con.Open(); var r = DatabaseCommandHelper.GetCommand("Select TableName from CachedAggregateConfigurationResults WHERE AggregateConfiguration_ID = " + configuration.ID + " AND Operation = '" + operation + "'", con).ExecuteReader(); if (r.Read()) { string tableName = r["TableName"].ToString(); return(_database.ExpectTable(tableName)); } } return(null); }
public void Execute_should_return_expected_result_when_UseCursor_is_set( [Values(null, false, true)] bool? useCursor, [Values(false, true)] bool async) { RequireServer.Check().Supports(Feature.Aggregate); EnsureTestData(); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { UseCursor = useCursor }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().HaveCount(1); }
public void BatchSize_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); subject.BatchSize = 23; var result = subject.BatchSize; result.Should().Be(23); }
public void CreateCommand_should_return_the_expected_result_when_UseCursor_is_set( [Values(null, false, true)] bool? useCursor, [Values(false, true)] bool useServerVersionSupportingAggregateCursorResult) { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { UseCursor = useCursor }; var serverVersion = Feature.AggregateCursorResult.SupportedOrNotSupportedVersion(useServerVersionSupportingAggregateCursorResult); var result = subject.CreateCommand(serverVersion); var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "cursor", () => new BsonDocument(), useCursor.GetValueOrDefault(true) && Feature.AggregateCursorResult.IsSupported(serverVersion) } }; result.Should().Be(expectedResult); }
public static ListPropertyType GetListPropertyType(ColumnDescriptor columnDescriptor, AggregateOperation aggregateOperation) { var propertyType = columnDescriptor.DataSchema.GetWrappedValueType(columnDescriptor.PropertyType); if (aggregateOperation != null) { propertyType = aggregateOperation.GetPropertyType(propertyType); } if (propertyType == typeof(bool)) { return(ListPropertyType.TRUE_FALSE); } if (propertyType.IsPrimitive) { return(ListPropertyType.NUMBER); } return(ListPropertyType.TEXT); }
public AnnotationExpression ChangeAggregateOperation(AggregateOperation aggregateOperation) { return(ChangeProp(ImClone(this), im => im.AggregateOperation = aggregateOperation)); }
public void CreateCommand_should_return_the_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Linearizable)] ReadConcernLevel? level) { var readConcern = new ReadConcern(level); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { ReadConcern = readConcern }; var result = subject.CreateCommand(Feature.ReadConcern.FirstSupportedVersion); var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "readConcern", () => readConcern.ToBsonDocument(), level != null }, { "cursor", new BsonDocument() } }; result.Should().Be(expectedResult); }
public IHasFullyQualifiedNameToo GetLatestResultsTableUnsafe(AggregateConfiguration configuration, AggregateOperation operation, out string sql) { var syntax = _database.Server.GetQuerySyntaxHelper(); var mgrTable = _database.ExpectTable(ResultsManagerTable); using (var con = _server.GetConnection()) { con.Open(); using (var cmd = DatabaseCommandHelper.GetCommand( $@"Select {syntax.EnsureWrapped("TableName")}, {syntax.EnsureWrapped("SqlExecuted")} from {mgrTable.GetFullyQualifiedName()} WHERE {syntax.EnsureWrapped("AggregateConfiguration_ID")} = {configuration.ID} AND {syntax.EnsureWrapped("Operation")} = '{operation}'", con)) { using (var r = cmd.ExecuteReader()) if (r.Read()) { string tableName = r["TableName"].ToString(); sql = r["SqlExecuted"] as string; return(_database.ExpectTable(tableName)); } } } sql = null; return(null); }
public IHasFullyQualifiedNameToo GetLatestResultsTableUnsafe(AggregateConfiguration configuration, AggregateOperation operation) { return(GetLatestResultsTableUnsafe(configuration, operation, out _)); }
/// <summary> /// Returns the name of the query cache results table for <paramref name="configuration"/> if the <paramref name="currentSql"/> matches /// the SQL run when the cache result was generated. Returns null if no cache result is found or there are changes in the <paramref name="currentSql"/> /// since the cache result was generated. /// </summary> /// <param name="configuration"></param> /// <param name="operation"></param> /// <param name="currentSql"></param> /// <returns></returns> public IHasFullyQualifiedNameToo GetLatestResultsTable(AggregateConfiguration configuration, AggregateOperation operation, string currentSql) { var syntax = _database.Server.GetQuerySyntaxHelper(); var mgrTable = _database.ExpectTable(ResultsManagerTable); using (var con = _server.GetConnection()) { con.Open(); using (var cmd = DatabaseCommandHelper.GetCommand( $@"Select {syntax.EnsureWrapped("TableName")}, {syntax.EnsureWrapped("SqlExecuted")} from {mgrTable.GetFullyQualifiedName()} WHERE {syntax.EnsureWrapped("AggregateConfiguration_ID")} = {configuration.ID} AND {syntax.EnsureWrapped("Operation")} = '{operation}'", con)) { using (var r = cmd.ExecuteReader()) if (r.Read()) { if (IsMatchOnSqlExecuted(r, currentSql)) { string tableName = r["TableName"].ToString(); return(_database.ExpectTable(tableName)); } return(null); //this means that there was outdated SQL, we could show this to user at some point } } } return(null); }
public void Executing_with_matching_documents_without_a_cursor( [Values(false, true)] bool async) { RequireServer.Where(minimumVersion: "2.4.0"); EnsureTestData(); var pipeline = BsonDocument.Parse("{$match: {_id: { $gt: 3}}}"); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, new[] { pipeline }, BsonDocumentSerializer.Instance, _messageEncoderSettings) { UseCursor = false }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().HaveCount(2); }
public IndexedPropertyDescriptor MakePropertyDescriptor(int index, ImmutableList <object> columnHeaderKey, PropertyDescriptor originalPropertyDescriptor, IColumnCaption caption, AggregateOperation aggregateOperation) { IColumnCaption qualifiedCaption; if (columnHeaderKey.Count == 0) { qualifiedCaption = caption; } else { qualifiedCaption = new CaptionComponentList(columnHeaderKey.Concat(new[] { caption }) .Select(CaptionComponentList.MakeCaptionComponent)); } var attributes = DataSchema.GetAggregateAttributes(originalPropertyDescriptor, aggregateOperation).ToArray(); return(new IndexedPropertyDescriptor(DataSchema, index, aggregateOperation.GetPropertyType(originalPropertyDescriptor.PropertyType), qualifiedCaption, attributes)); }
public void Execute_should_throw_when_binding_is_null( [Values(false, true)] bool async) { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); Exception exception; if (async) { exception = Record.Exception(() => subject.ExecuteAsync(null, CancellationToken.None).GetAwaiter().GetResult()); } else { exception = Record.Exception(() => subject.Execute(null, CancellationToken.None)); } var argumentNullException = exception.Should().BeOfType<ArgumentNullException>().Subject; argumentNullException.ParamName.Should().Be("binding"); }
public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] bool caseSensitive, [Values(false, true)] bool async) { RequireServer.Check().Supports(Feature.Aggregate, Feature.Collation); EnsureTestData(); var collation = new Collation("en_US", caseLevel: caseSensitive, strength: CollationStrength.Primary); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { Collation = collation }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().HaveCount(caseSensitive ? 1 : 2); }
public void CreateCommand_should_throw_when_ReadConcern_is_set_but_not_supported() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { ReadConcern = new ReadConcern(ReadConcernLevel.Linearizable) }; var exception = Record.Exception(() => subject.CreateCommand(Feature.ReadConcern.LastNotSupportedVersion)); exception.Should().BeOfType<MongoClientException>(); }
public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000)] int? milliseconds, [Values(false, true)] bool async) { RequireServer.Check().Supports(Feature.Aggregate, Feature.MaxTime); EnsureTestData(); var maxTime = milliseconds == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(milliseconds.Value); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { MaxTime = maxTime }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().HaveCount(1); }
public void SelectAggregateOperation(AggregateOperation aggregateOperation) { comboAggregateOp.SelectedItem = aggregateOperation; }
public IHasFullyQualifiedNameToo GetLatestResultsTable(AggregateConfiguration configuration, AggregateOperation operation, string currentSql) { using (var con = _server.GetConnection()) { con.Open(); var cmd = DatabaseCommandHelper.GetCommand("Select TableName,SqlExecuted from CachedAggregateConfigurationResults WHERE AggregateConfiguration_ID = " + configuration.ID + " AND Operation = '" + operation + "'", con); var r = cmd.ExecuteReader(); if (r.Read()) { if (IsMatchOnSqlExecuted(r, currentSql)) { string tableName = r["TableName"].ToString(); return(_database.ExpectTable(tableName)); } else { return(null); //this means that there was outdated SQL, we could show this to user at some point } } } return(null); }
public void Execute_should_throw_when_pipeline_ends_with_out( [Values(false, true)] bool async) { var pipeline = new [] { BsonDocument.Parse("{ $out : \"xyz\" }") }; var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, pipeline, __resultSerializer, _messageEncoderSettings); var exception = Record.Exception(() => ExecuteOperation(subject, async)); var argumentException = exception.Should().BeOfType<ArgumentException>().Subject; argumentException.ParamName.Should().Be("pipeline"); }
public void Collation_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); var collation = new Collation("en_US"); subject.Collation = collation; var result = subject.Collation; result.Should().BeSameAs(collation); }
public void Execute_should_throw_when_Collation_is_set_but_not_supported( [Values(false, true)] bool async) { RequireServer.Check().Supports(Feature.Aggregate).DoesNotSupport(Feature.Collation); var collation = new Collation("en_US"); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { Collation = collation }; var exception = Record.Exception(() => ExecuteOperation(subject, async)); exception.Should().BeOfType<NotSupportedException>(); }
public void MaxTime_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); var value = TimeSpan.FromSeconds(2); subject.MaxTime = value; var result = subject.MaxTime; result.Should().Be(value); }
public void Execute_should_throw_when_ReadConcern_is_set_but_not_supported( [Values(false, true)] bool async) { RequireServer.Check().Supports(Feature.Aggregate).DoesNotSupport(Feature.ReadConcern); var readConcern = new ReadConcern(ReadConcernLevel.Linearizable); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { ReadConcern = readConcern }; var exception = Record.Exception(() => ExecuteOperation(subject, async)); exception.Should().BeOfType<MongoClientException>(); }
public void ReadConcern_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); var value = new ReadConcern(ReadConcernLevel.Linearizable); subject.ReadConcern = value; var result = subject.ReadConcern; result.Should().BeSameAs(value); }
public void AllowDiskUse_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); subject.AllowDiskUse = true; var result = subject.AllowDiskUse; result.Should().Be(true); }
public void UseCursor_get_and_set_should_work() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings); subject.UseCursor = true; var result = subject.UseCursor; result.Should().BeTrue(); }
public void CreateCommand_should_create_the_correct_command( [Values("2.4.0", "2.6.0", "2.8.0", "3.0.0", "3.2.0")] string serverVersion, [Values(null, false, true)] bool? allowDiskUse, [Values(null, 10, 20)] int? batchSize, [Values(null, 2000)] int? maxTime, [Values(null, ReadConcernLevel.Local, ReadConcernLevel.Majority)] ReadConcernLevel? readConcernLevel, [Values(null, false, true)] bool? useCursor) { var semanticServerVersion = SemanticVersion.Parse(serverVersion); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, Enumerable.Empty<BsonDocument>(), BsonDocumentSerializer.Instance, _messageEncoderSettings) { AllowDiskUse = allowDiskUse, BatchSize = batchSize, MaxTime = maxTime.HasValue ? TimeSpan.FromMilliseconds(maxTime.Value) : (TimeSpan?)null, ReadConcern = new ReadConcern(readConcernLevel), UseCursor = useCursor }; var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(subject.Pipeline) }, { "allowDiskUse", () => allowDiskUse.Value, allowDiskUse.HasValue }, { "maxTimeMS", () => maxTime.Value, maxTime.HasValue } }; if (!subject.ReadConcern.IsServerDefault) { expectedResult["readConcern"] = subject.ReadConcern.ToBsonDocument(); } if (semanticServerVersion >= new SemanticVersion(2, 6, 0) && useCursor.GetValueOrDefault(true)) { expectedResult["cursor"] = new BsonDocument { { "batchSize", () => batchSize.Value, batchSize.HasValue } }; } if (!subject.ReadConcern.IsSupported(semanticServerVersion)) { Action act = () => subject.CreateCommand(semanticServerVersion); act.ShouldThrow<MongoClientException>(); } else { var result = subject.CreateCommand(semanticServerVersion); result.Should().Be(expectedResult); } }
public void CreateCommand_should_return_the_expected_result_when_AllowDiskUse_is_set( [Values(null, false, true)] bool? allowDiskUse) { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { AllowDiskUse = allowDiskUse }; var result = subject.CreateCommand(Feature.AggregateCursorResult.FirstSupportedVersion); var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "allowDiskUse", () => allowDiskUse.Value, allowDiskUse != null }, { "cursor", new BsonDocument() } }; result.Should().Be(expectedResult); }
public void Executing_with_no_matching_documents_using_a_cursor( [Values(false, true)] bool async) { var pipeline = BsonDocument.Parse("{$match: {_id: { $gt: 5}}}"); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, new[] { pipeline }, BsonDocumentSerializer.Instance, _messageEncoderSettings) { UseCursor = true }; var cursor = ExecuteOperation(subject, async); var result = ReadCursorToEnd(cursor, async); result.Should().NotBeNull(); result.Should().BeEmpty(); }
public void CreateCommand_should_return_the_expected_result_when_BatchSize_is_set( [Values(null, 1)] int? batchSize, [Values(false, true)] bool useServerVersionSupportingAggregateCursorResult) { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { BatchSize = batchSize }; var serverVersion = Feature.AggregateCursorResult.SupportedOrNotSupportedVersion(useServerVersionSupportingAggregateCursorResult); var result = subject.CreateCommand(serverVersion); BsonDocument cursor = null; if (Feature.AggregateCursorResult.IsSupported(serverVersion)) { cursor = new BsonDocument { { "batchSize", () => batchSize.Value, batchSize != null } }; } var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "cursor", () => cursor, cursor != null } }; result.Should().Be(expectedResult); }
public void CreateCommand_should_return_the_expected_result_when_Collation_is_set( [Values(null, "en_US", "fr_CA")] string locale) { var collation = locale == null ? null : new Collation(locale); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { Collation = collation }; var result = subject.CreateCommand(Feature.Collation.FirstSupportedVersion); var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "collation", () => new BsonDocument("locale", locale), collation != null }, { "cursor", new BsonDocument() } }; result.Should().Be(expectedResult); }
public void CreateCommand_should_throw_when_Collation_is_set() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { Collation = new Collation("en_US") }; var exception = Record.Exception(() => subject.CreateCommand(Feature.Collation.LastNotSupportedVersion)); exception.Should().BeOfType<NotSupportedException>(); }
public void MaxTime_should_have_the_correct_value() { var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, Enumerable.Empty<BsonDocument>(), BsonDocumentSerializer.Instance, _messageEncoderSettings); subject.MaxTime.Should().Be(null); subject.MaxTime = TimeSpan.FromSeconds(2); subject.MaxTime.Should().Be(TimeSpan.FromSeconds(2)); }
public void CreateCommand_should_return_the_expected_result_when_MaxTime_is_set( [Values(null, 1)] int? milliSeconds) { var maxTime = milliSeconds == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(milliSeconds.Value); var subject = new AggregateOperation<BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings) { MaxTime = maxTime }; var result = subject.CreateCommand(Feature.AggregateCursorResult.FirstSupportedVersion); var expectedResult = new BsonDocument { { "aggregate", _collectionNamespace.CollectionName }, { "pipeline", new BsonArray(__pipeline) }, { "maxTimeMS", () => maxTime.Value.TotalMilliseconds, maxTime != null }, { "cursor", new BsonDocument() } }; result.Should().Be(expectedResult); }
public AggregateColumn(ColumnId sourceColumn, AggregateOperation aggregateOperation) : base(sourceColumn) { AggregateOperation = aggregateOperation; }
public IndexedPropertyDescriptor MakePropertyDescriptor(int index, ImmutableList <object> columnHeaderKey, PropertyDescriptor originalPropertyDescriptor, IColumnCaption caption, AggregateOperation aggregateOperation) { IColumnCaption qualifiedCaption; PivotedColumnId pivotedColumnId = null; if (columnHeaderKey.Count == 0) { qualifiedCaption = caption; } else { var pivotCaptionComponents = columnHeaderKey.Select(CaptionComponentList.MakeCaptionComponent).ToList(); qualifiedCaption = new CaptionComponentList(pivotCaptionComponents.Append(caption)); pivotedColumnId = new PivotedColumnId(columnHeaderKey, new CaptionComponentList(pivotCaptionComponents), caption, caption); } var attributes = DataSchema.GetAggregateAttributes(originalPropertyDescriptor, aggregateOperation).ToArray(); return(new IndexedPropertyDescriptor(DataSchema, index, aggregateOperation.GetPropertyType(originalPropertyDescriptor.PropertyType), qualifiedCaption, pivotedColumnId, attributes)); }