|
| 1 | +/* Copyright 2010-present MongoDB Inc. |
| 2 | +* |
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +* you may not use this file except in compliance with the License. |
| 5 | +* You may obtain a copy of the License at |
| 6 | +* |
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +* |
| 9 | +* Unless required by applicable law or agreed to in writing, software |
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +* See the License for the specific language governing permissions and |
| 13 | +* limitations under the License. |
| 14 | +*/ |
| 15 | + |
| 16 | +using System; |
| 17 | +using FluentAssertions; |
| 18 | +using Xunit; |
| 19 | + |
| 20 | +namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Jira |
| 21 | +{ |
| 22 | + public class CSharp4746Tests : Linq3IntegrationTest |
| 23 | + { |
| 24 | + [Fact] |
| 25 | + public void UpdateDefinitionBuilder_Combine_should_throw_when_PipelineUpdateDefinition_is_combined_with_another_update() |
| 26 | + { |
| 27 | + var pipeline = new EmptyPipelineDefinition<C>(); |
| 28 | + var pipelineUpdate = Builders<C>.Update.Pipeline(pipeline); |
| 29 | + var setUpdate = Builders<C>.Update.Set(x => x.X, 2); |
| 30 | + |
| 31 | + var exception = Record.Exception(() => new UpdateDefinitionBuilder<C>().Combine(pipelineUpdate, setUpdate)); |
| 32 | + |
| 33 | + exception.Should().BeOfType<InvalidOperationException>(); |
| 34 | + } |
| 35 | + |
| 36 | + [Fact] |
| 37 | + public void UpdateDefinitionBuilder_Combine_should_throw_when_an_update_is_combined_with_a_PipelineUpdateDefinition() |
| 38 | + { |
| 39 | + var setUpdate = Builders<C>.Update.Set(x => x.X, 2); |
| 40 | + var pipeline = new EmptyPipelineDefinition<C>(); |
| 41 | + var pipelineUpdate = Builders<C>.Update.Pipeline(pipeline); |
| 42 | + |
| 43 | + var exception = Record.Exception(() => new UpdateDefinitionBuilder<C>().Combine(setUpdate, pipelineUpdate)); |
| 44 | + |
| 45 | + exception.Should().BeOfType<InvalidOperationException>(); |
| 46 | + } |
| 47 | + |
| 48 | + private class C |
| 49 | + { |
| 50 | + public int Id { get; set; } |
| 51 | + public int X { get; set; } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments