|
| 1 | +/* Copyright 2018-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 System.Collections.Generic; |
| 18 | +using System.Linq; |
| 19 | +using System.Text; |
| 20 | +using System.Threading.Tasks; |
| 21 | +using FluentAssertions; |
| 22 | +using Xunit; |
| 23 | + |
| 24 | +namespace MongoDB.Driver.Core.Connections |
| 25 | +{ |
| 26 | + public class KeepAliveValuesTests |
| 27 | + { |
| 28 | + [Theory] |
| 29 | + [InlineData(0)] |
| 30 | + [InlineData(1)] |
| 31 | + [InlineData(ulong.MaxValue)] |
| 32 | + public void OnOff_get_and_set_work(ulong value) |
| 33 | + { |
| 34 | + var subject = new KeepAliveValues(); |
| 35 | + |
| 36 | + subject.OnOff = value; |
| 37 | + var result = subject.OnOff; |
| 38 | + |
| 39 | + result.Should().Be(value); |
| 40 | + } |
| 41 | + |
| 42 | + [Theory] |
| 43 | + [InlineData(0)] |
| 44 | + [InlineData(1)] |
| 45 | + [InlineData(ulong.MaxValue)] |
| 46 | + public void KeepAliveTime_get_and_set_work(ulong value) |
| 47 | + { |
| 48 | + var subject = new KeepAliveValues(); |
| 49 | + |
| 50 | + subject.KeepAliveTime = value; |
| 51 | + var result = subject.KeepAliveTime; |
| 52 | + |
| 53 | + result.Should().Be(value); |
| 54 | + } |
| 55 | + |
| 56 | + [Theory] |
| 57 | + [InlineData(0)] |
| 58 | + [InlineData(1)] |
| 59 | + [InlineData(ulong.MaxValue)] |
| 60 | + public void KeepAliveInterval_get_and_set_work(ulong value) |
| 61 | + { |
| 62 | + var subject = new KeepAliveValues(); |
| 63 | + |
| 64 | + subject.KeepAliveInterval = value; |
| 65 | + var result = subject.KeepAliveInterval; |
| 66 | + |
| 67 | + result.Should().Be(value); |
| 68 | + } |
| 69 | + |
| 70 | + [Theory] |
| 71 | + [InlineData(0x0102030405060708, 0x0203040506070809, 0x030405060708090a, new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03 })] |
| 72 | + [InlineData(0xf1f2f3f4f5f6f7f8, 0xf2f3f4f5f6f7f8f9, 0xf3f4f5f6f7f8f9fa, new byte[] { 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3 })] |
| 73 | + public void ToBytes_should_return_expected_result(ulong onOff, ulong keepAliveTime, ulong keepAliveInterval, byte[] expectedResult) |
| 74 | + { |
| 75 | + var subject = new KeepAliveValues |
| 76 | + { |
| 77 | + OnOff = onOff, |
| 78 | + KeepAliveTime = keepAliveTime, |
| 79 | + KeepAliveInterval = keepAliveInterval |
| 80 | + }; |
| 81 | + |
| 82 | + var result = subject.ToBytes(); |
| 83 | + |
| 84 | + result.Should().Equal(expectedResult); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments