Permalink
Browse files

Fixing the tests

Fixing warnings
  • Loading branch information...
ayende committed Feb 25, 2012
1 parent dff84fc commit 29161a8c3f95fc4fbcfa4b0e3a0d46087ec7c1bb
@@ -77,8 +77,9 @@ public void WillGetAnErrorWhenTryingToLoginIfUserDoesNotExists()
using (var session = store.OpenAsyncSession())
{
session.Store(new { Name = "Sprite", Age = 321 });
- var saveChangesAsync = session.SaveChangesAsync();
- var webException = (WebException)Assert.Throws<AggregateException>(() => saveChangesAsync.Wait()).ExtractSingleInnerException();
+ var saveChangesAsync = session.SaveChangesAsync();
+ var invalidOperationException = (InvalidOperationException)Assert.Throws<AggregateException>(() => saveChangesAsync.Wait()).ExtractSingleInnerException();
+ var webException = invalidOperationException.InnerException as WebException;
Assert.Equal(HttpStatusCode.Unauthorized, ((HttpWebResponse) webException.Response).StatusCode);
}
}
@@ -1,5 +1,5 @@
extern alias database;
-
+using System;
using System.Linq;
using System.Net;
using Raven.Bundles.Authentication;
@@ -100,7 +100,8 @@ public void WillGetAnErrorWhenTryingToLoginIfUserDoesNotExists()
using (var session = store.OpenSession())
{
session.Store(new { Name = "Sprite", Age = 321 });
- var webException = Assert.Throws<WebException>(() => session.SaveChanges());
+ var invalidOperationException = Assert.Throws<InvalidOperationException>(() => session.SaveChanges());
+ var webException = invalidOperationException.InnerException as WebException;
Assert.Equal(HttpStatusCode.Unauthorized, ((HttpWebResponse) webException.Response).StatusCode);
}
@@ -3,9 +3,7 @@
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
-#if !SILVERLIGHT
using System.IO;
-using System.IO.Compression;
using System.Net;
namespace Raven.Abstractions.Connection
@@ -15,6 +13,23 @@ namespace Raven.Abstractions.Connection
/// </summary>
public static class WebResponseExtensions
{
+#if !SILVERLIGHT
+ /// <summary>
+ /// Gets the response stream with HTTP decompression.
+ /// </summary>
+ /// <param name="response">The response.</param>
+ /// <returns></returns>
+ public static Stream GetResponseStreamWithHttpDecompression(this WebResponse response)
+ {
+ var stream = response.GetResponseStream();
+ var encoding = response.Headers["Content-Encoding"];
+ if (encoding != null && encoding.Contains("gzip"))
+ stream = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress);
+ else if (encoding != null && encoding.Contains("deflate"))
+ stream = new System.IO.Compression.DeflateStream(stream, System.IO.Compression.CompressionMode.Decompress);
+ return stream;
+ }
+#else
/// <summary>
/// Gets the response stream with HTTP decompression.
/// </summary>
@@ -25,11 +40,11 @@ public static Stream GetResponseStreamWithHttpDecompression(this WebResponse res
var stream = response.GetResponseStream();
var encoding = response.Headers["Content-Encoding"];
if (encoding != null && encoding.Contains("gzip"))
- stream = new GZipStream(stream, CompressionMode.Decompress);
+ stream = new Ionic.Zlib.GZipStream(stream, Ionic.Zlib.CompressionMode.Decompress);
else if (encoding != null && encoding.Contains("deflate"))
- stream = new DeflateStream(stream, CompressionMode.Decompress);
+ stream = new Ionic.Zlib.DeflateStream(stream, Ionic.Zlib.CompressionMode.Decompress);
return stream;
}
+#endif
}
}
-#endif
@@ -515,8 +515,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="Int16"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(short value)
{
return new RavenJValue(value);
@@ -526,8 +528,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="UInt16"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(ushort value)
{
return new RavenJValue(value);
@@ -597,8 +601,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="Nullable{Int16}"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(short? value)
{
return new RavenJValue(value);
@@ -608,8 +614,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="Nullable{UInt16}"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(ushort? value)
{
return new RavenJValue(value);
@@ -619,8 +627,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="Nullable{UInt32}"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(uint? value)
{
return new RavenJValue(value);
@@ -630,8 +640,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="Nullable{UInt64}"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(ulong? value)
{
return new RavenJValue(value);
@@ -671,8 +683,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="UInt32"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(uint value)
{
return new RavenJValue(value);
@@ -682,8 +696,10 @@ internal virtual void AddForCloning(string key, RavenJToken token)
/// Performs an implicit conversion from <see cref="UInt64"/> to <see cref="RavenJToken"/>.
/// </summary>
/// <param name="value">The value to create a <see cref="RavenJValue"/> from.</param>
- /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
- [CLSCompliant(false)]
+ /// <returns>The <see cref="RavenJValue"/> initialized with the specified value.</returns>
+#if !SILVERLIGHT
+ [CLSCompliant(false)]
+#endif
public static implicit operator RavenJToken(ulong value)
{
return new RavenJValue(value);
@@ -190,7 +190,9 @@ public override void WriteValue(int value)
/// Writes a <see cref="UInt32"/> value.
/// </summary>
/// <param name="value">The <see cref="UInt32"/> value to write.</param>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public override void WriteValue(uint value)
{
base.WriteValue(value);
@@ -211,7 +213,9 @@ public override void WriteValue(long value)
/// Writes a <see cref="UInt64"/> value.
/// </summary>
/// <param name="value">The <see cref="UInt64"/> value to write.</param>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public override void WriteValue(ulong value)
{
base.WriteValue(value);
@@ -262,7 +266,9 @@ public override void WriteValue(short value)
/// Writes a <see cref="UInt16"/> value.
/// </summary>
/// <param name="value">The <see cref="UInt16"/> value to write.</param>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public override void WriteValue(ushort value)
{
base.WriteValue(value);
@@ -293,7 +299,9 @@ public override void WriteValue(byte value)
/// Writes a <see cref="SByte"/> value.
/// </summary>
/// <param name="value">The <see cref="SByte"/> value to write.</param>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public override void WriteValue(sbyte value)
{
base.WriteValue(value);
@@ -76,7 +76,9 @@ public RavenJValue(long value)
/// Initializes a new instance of the <see cref="RavenJValue"/> class with the given value.
/// </summary>
/// <param name="value">The value.</param>
+#if !SILVERLIGHT
[CLSCompliant(false)]
+#endif
public RavenJValue(ulong value)
: this(value, JTokenType.Integer)
{
@@ -8,9 +8,8 @@
using System.Net;
#if SILVERLIGHT
using System.Net.Browser;
-#else
-using Raven.Abstractions.Connection;
#endif
+using Raven.Abstractions.Connection;
using Raven.Abstractions.Data;
using Raven.Abstractions.Extensions;
using Raven.Client.Connection;
@@ -30,7 +29,6 @@
using Raven.Client.Listeners;
using Raven.Client.Silverlight.Connection;
using Raven.Client.Silverlight.Connection.Async;
-
#endif
namespace Raven.Client.Document
@@ -533,15 +531,18 @@ private void InitializeSecurity()
}
catch (WebException we)
{
+ string message;
try
{
- var text = new StreamReader(we.Response.GetResponseStream()).ReadToEnd();
- throw new InvalidOperationException("Failure when trying to get OAuth token:\r\n" + text, we);
+ var text = new StreamReader(we.Response.GetResponseStreamWithHttpDecompression()).ReadToEnd();
+ message = "Failure when trying to get OAuth token:\r\n" + text;
}
catch (Exception)
{
throw new InvalidOperationException("Failure when trying to get OAuth token", we);
}
+ throw new InvalidOperationException(message, we);
+
}
};
#endif
@@ -578,15 +579,17 @@ private void InitializeSecurity()
{
throw new InvalidOperationException("Failure when trying to get OAuth token", e);
}
+ string message;
try
{
- var text = new StreamReader(we.Response.GetResponseStream()).ReadToEnd();
- throw new InvalidOperationException("Failure when trying to get OAuth token:\r\n" + text, we);
+ var text = new StreamReader(we.Response.GetResponseStreamWithHttpDecompression()).ReadToEnd();
+ message = "Failure when trying to get OAuth token:\r\n" + text;
}
catch (Exception)
{
throw new InvalidOperationException("Failure when trying to get OAuth token", e);
}
+ throw new InvalidOperationException(message, we);
}
catch(Exception e)
{
@@ -26,11 +26,6 @@ public WrapperGrouping(IGrouping<dynamic, dynamic> inner)
this.inner = inner;
}
- public IEnumerator<dynamic> GetEnumerator()
- {
- return inner.GetEnumerator();
- }
-
public dynamic Key
{
get { return inner.Key; }
@@ -26,7 +26,6 @@ public class BackupOperation
private string to;
private bool incrementalBackup;
private string src;
- private int backupCount;
private static readonly Logger log = LogManager.GetCurrentClassLogger();
public BackupOperation(DocumentDatabase database, string src, string to, bool incrementalBackup)

0 comments on commit 29161a8

Please sign in to comment.