Skip to content

Commit

Permalink
CSHARP-1993: Refactor pull request.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstam committed Jun 7, 2017
1 parent e0c1f6c commit 275fd15
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Please see our [guidelines](CONTRIBUTING.md) for contributing to the driver.
* Jacob Jewell jacobjewell@eflexsystems.com
* Danny Kendrick https://github.com/dkendrick
* Brian Knight brianknight10@gmail.com
* Anatoly Koperin https://github.com/ExM
* Nik Kolev nkolev@gmail.com
* Oleg Kosmakov kosmakoff@gmail.com
* Maksim Krautsou https://github.com/MaKCbIMKo
Expand Down
8 changes: 4 additions & 4 deletions src/MongoDB.Driver.GridFS/GridFSSeekableDownloadStream.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015-2016 MongoDB Inc.
/* Copyright 2015-2017 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -125,16 +125,16 @@ public override long Seek(long offset, SeekOrigin origin)
{
case SeekOrigin.Begin: newPosition = offset; break;
case SeekOrigin.Current: newPosition = _position + offset; break;
case SeekOrigin.End: newPosition = FileInfo.Length + offset; break;
case SeekOrigin.End: newPosition = Length + offset; break;
default: throw new ArgumentException("Invalid origin.", "origin");
}
if (newPosition < 0)
{
throw new IOException("Position must be greater than or equal to zero.");
}
if (FileInfo.Length <= newPosition)
if (newPosition > Length)
{
throw new IOException("Position must be less than to length of stream.");
throw new IOException("Position must be less than or equal to the length of the stream.");
}
Position = newPosition;
return newPosition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015-2016 MongoDB Inc.
/* Copyright 2015-2017 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -195,7 +195,7 @@ public void Read_should_throw_when_offset_is_invalid(int bufferLength, int offse
[InlineData(9, 1, SeekOrigin.Begin, 1)]
[InlineData(0, 1, SeekOrigin.Current, 1)]
[InlineData(5, 1, SeekOrigin.Current, 6)]
[InlineData(8, 1, SeekOrigin.Current, 9)]
[InlineData(9, 1, SeekOrigin.Current, 10)]
[InlineData(0, -1, SeekOrigin.End, 9)]
[InlineData(5, -1, SeekOrigin.End, 9)]
[InlineData(9, -1, SeekOrigin.End, 9)]
Expand All @@ -216,13 +216,22 @@ public void Seek_should_return_expected_result(
[Theory]
[InlineData(0, -1, SeekOrigin.Begin)]
[InlineData(5, -1, SeekOrigin.Begin)]
[InlineData(9, 10, SeekOrigin.Begin)]
[InlineData(10, -1, SeekOrigin.Begin)]
[InlineData(0, 11, SeekOrigin.Begin)]
[InlineData(5, 11, SeekOrigin.Begin)]
[InlineData(10, 11, SeekOrigin.Begin)]
[InlineData(0, -1, SeekOrigin.Current)]
[InlineData(5, -6, SeekOrigin.Current)]
[InlineData(8, 3, SeekOrigin.Current)]
[InlineData(0, 0, SeekOrigin.End)]
[InlineData(10, -11, SeekOrigin.Current)]
[InlineData(0, 11, SeekOrigin.Current)]
[InlineData(5, 6, SeekOrigin.Current)]
[InlineData(10, 1, SeekOrigin.Current)]
[InlineData(0, 1, SeekOrigin.End)]
[InlineData(5, 1, SeekOrigin.End)]
[InlineData(9, -11, SeekOrigin.End)]
[InlineData(10, 1, SeekOrigin.End)]
[InlineData(0, -11, SeekOrigin.End)]
[InlineData(5, -11, SeekOrigin.End)]
[InlineData(10, -11, SeekOrigin.End)]
public void Seek_should_throw_when_new_position_is_out_of_range(
long position,
long offset,
Expand Down

0 comments on commit 275fd15

Please sign in to comment.