Skip to content

Commit 275fd15

Browse files
committed
CSHARP-1993: Refactor pull request.
1 parent e0c1f6c commit 275fd15

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Please see our [guidelines](CONTRIBUTING.md) for contributing to the driver.
101101
* Jacob Jewell [email protected]
102102
* Danny Kendrick https://github.com/dkendrick
103103
* Brian Knight [email protected]
104+
* Anatoly Koperin https://github.com/ExM
104105
* Nik Kolev [email protected]
105106
* Oleg Kosmakov [email protected]
106107
* Maksim Krautsou https://github.com/MaKCbIMKo

src/MongoDB.Driver.GridFS/GridFSSeekableDownloadStream.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015-2016 MongoDB Inc.
1+
/* Copyright 2015-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -125,16 +125,16 @@ public override long Seek(long offset, SeekOrigin origin)
125125
{
126126
case SeekOrigin.Begin: newPosition = offset; break;
127127
case SeekOrigin.Current: newPosition = _position + offset; break;
128-
case SeekOrigin.End: newPosition = FileInfo.Length + offset; break;
128+
case SeekOrigin.End: newPosition = Length + offset; break;
129129
default: throw new ArgumentException("Invalid origin.", "origin");
130130
}
131131
if (newPosition < 0)
132132
{
133133
throw new IOException("Position must be greater than or equal to zero.");
134134
}
135-
if (FileInfo.Length <= newPosition)
135+
if (newPosition > Length)
136136
{
137-
throw new IOException("Position must be less than to length of stream.");
137+
throw new IOException("Position must be less than or equal to the length of the stream.");
138138
}
139139
Position = newPosition;
140140
return newPosition;

tests/MongoDB.Driver.GridFS.Tests/GridFSSeekableDownloadStreamTests.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015-2016 MongoDB Inc.
1+
/* Copyright 2015-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -195,7 +195,7 @@ public void Read_should_throw_when_offset_is_invalid(int bufferLength, int offse
195195
[InlineData(9, 1, SeekOrigin.Begin, 1)]
196196
[InlineData(0, 1, SeekOrigin.Current, 1)]
197197
[InlineData(5, 1, SeekOrigin.Current, 6)]
198-
[InlineData(8, 1, SeekOrigin.Current, 9)]
198+
[InlineData(9, 1, SeekOrigin.Current, 10)]
199199
[InlineData(0, -1, SeekOrigin.End, 9)]
200200
[InlineData(5, -1, SeekOrigin.End, 9)]
201201
[InlineData(9, -1, SeekOrigin.End, 9)]
@@ -216,13 +216,22 @@ public void Seek_should_return_expected_result(
216216
[Theory]
217217
[InlineData(0, -1, SeekOrigin.Begin)]
218218
[InlineData(5, -1, SeekOrigin.Begin)]
219-
[InlineData(9, 10, SeekOrigin.Begin)]
219+
[InlineData(10, -1, SeekOrigin.Begin)]
220+
[InlineData(0, 11, SeekOrigin.Begin)]
221+
[InlineData(5, 11, SeekOrigin.Begin)]
222+
[InlineData(10, 11, SeekOrigin.Begin)]
220223
[InlineData(0, -1, SeekOrigin.Current)]
221224
[InlineData(5, -6, SeekOrigin.Current)]
222-
[InlineData(8, 3, SeekOrigin.Current)]
223-
[InlineData(0, 0, SeekOrigin.End)]
225+
[InlineData(10, -11, SeekOrigin.Current)]
226+
[InlineData(0, 11, SeekOrigin.Current)]
227+
[InlineData(5, 6, SeekOrigin.Current)]
228+
[InlineData(10, 1, SeekOrigin.Current)]
229+
[InlineData(0, 1, SeekOrigin.End)]
224230
[InlineData(5, 1, SeekOrigin.End)]
225-
[InlineData(9, -11, SeekOrigin.End)]
231+
[InlineData(10, 1, SeekOrigin.End)]
232+
[InlineData(0, -11, SeekOrigin.End)]
233+
[InlineData(5, -11, SeekOrigin.End)]
234+
[InlineData(10, -11, SeekOrigin.End)]
226235
public void Seek_should_throw_when_new_position_is_out_of_range(
227236
long position,
228237
long offset,

0 commit comments

Comments
 (0)