Permalink
Browse files

Convert skipped tests to bug tracking tests.

For areas of the product known to fail, use a "bug tracking" test instead of Skip.

Rather than skipping tests, we simply assert that the bug hasn't yet been fixed. That way we:
 - remember to enable the test once the bug has been fixed
 - don't see build warnings in the interim
  • Loading branch information...
1 parent 833cc52 commit 015557d064aa05e28d4784a5cd92aaf0315de83d @davidmatson davidmatson committed Oct 26, 2012
@@ -37,15 +37,25 @@ public void Can_find_action(string actionName, string url)
Assert.Equal(actionName, action.Name);
}
- [Fact(Skip = "Requires improvements in Uri Parser so it can establish type of path segment prior to ActionName")]
+ [Fact]
public void Can_find_action_overload_using_bindingparameter_type()
{
string url = "http://server/service/Vehicles(8)/Container.Car/Wash";
IODataActionResolver resolver = new DefaultODataActionResolver();
ODataDeserializerContext context = new ODataDeserializerContext { Request = GetPostRequest(url), Model = GetModel() };
- IEdmFunctionImport action = resolver.Resolve(context);
- Assert.NotNull(action);
- Assert.Equal("Car", action.Parameters.First().Name);
+
+ // TODO: Requires improvements in Uri Parser so it can establish type of path segment prior to ActionName
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following assert shows the behavior with the bug and should be removed once the bug is fixed.
+
+ Assert.Throws<InvalidOperationException>(() => resolver.Resolve(context));
+
+ // TODO: DateTimeOffsets are not handled well in the uri parser
+ // The following calls show the behavior without the bug, and should be enabled once the bug is fixed.
+ //IEdmFunctionImport action = resolver.Resolve(context);
+ //Assert.NotNull(action);
+ //Assert.Equal("Car", action.Parameters.First().Name);
}
[Fact]
@@ -6,6 +6,7 @@
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
+using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http.Hosting;
@@ -137,21 +138,41 @@ public void TryGetInnerTypeForDelta_ReturnsFalse_ForNonDeltas(Type originalType)
Assert.False(success);
}
- [Fact(Skip = "OData formatter doesn't support writing nulls")]
+ [Fact]
public override Task WriteToStreamAsync_WhenObjectIsNull_WritesDataButDoesNotCloseStream()
{
- throw new NotImplementedException();
+ // Arrange
+ ODataMediaTypeFormatter formatter = CreateFormatter();
+ Mock<Stream> mockStream = new Mock<Stream>();
+ mockStream.Setup(s => s.CanWrite).Returns(true);
+ HttpContent content = new StringContent(String.Empty);
+ content.Headers.ContentType = new MediaTypeHeaderValue("application/atom+xml");
+
+ // Act
+ return formatter.WriteToStreamAsync(typeof(SampleType), null, mockStream.Object, content, null).ContinueWith(
+ writeTask =>
+ {
+ // Assert (OData formatter doesn't support writing nulls)
+ Assert.Equal(TaskStatus.Faulted, writeTask.Status);
+ Assert.Throws<SerializationException>(() => writeTask.ThrowIfFaulted(), "Cannot serialize a null 'entry'.");
+ mockStream.Verify(s => s.Close(), Times.Never());
+ mockStream.Verify(s => s.BeginWrite(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()), Times.Never());
+ });
}
- [Fact(Skip = "Tracked by Issue #339, Needs an implementation")]
+ // TODO: Uncomment the attribute below once the test exists.
+ //[Fact]
public override Task ReadFromStreamAsync_UsesCorrectCharacterEncoding(string content, string encoding, bool isDefaultEncoding)
{
+ // TODO: Tracked by Issue #339, Needs an implementation
throw new NotImplementedException();
}
- [Fact(Skip = "Tracked by Issue #339, Needs an implementation")]
+ // TODO: Uncomment the attribute below once the test exists.
+ //[Fact]
public override Task WriteToStreamAsync_UsesCorrectCharacterEncoding(string content, string encoding, bool isDefaultEncoding)
{
+ // TODO: Tracked by Issue #339, Needs an implementation
throw new NotImplementedException();
}
@@ -160,16 +160,21 @@ public void NegativeNumbers()
NotTesting);
}
- [Theory(Skip = "Enable once ODataUriParser handles DateTimeOffsets")]
+ [Theory]
[InlineData("DateTimeOffsetProp eq DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp == $it.DateTimeOffsetProp)")]
[InlineData("DateTimeOffsetProp ne DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp != $it.DateTimeOffsetProp)")]
[InlineData("DateTimeOffsetProp ge DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp >= $it.DateTimeOffsetProp)")]
[InlineData("DateTimeOffsetProp le DateTimeOffsetProp", "$it => ($it.DateTimeOffsetProp <= $it.DateTimeOffsetProp)")]
public void DateTimeOffsetInEqualities(string clause, string expectedExpression)
{
- VerifyQueryDeserialization<DataTypes>(
- "" + clause,
- expectedExpression);
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following assert shows the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Throws<ODataException>(() => Bind("" + clause));
+
+ // TODO: Enable once ODataUriParser handles DateTimeOffsets
+ // The following call shows the behavior without the bug, and should be enabled once the bug is fixed.
+ //VerifyQueryDeserialization<DataTypes>("" + clause, expectedExpression);
}
[Theory]
@@ -1035,7 +1040,7 @@ public void DateSecond()
NotTesting);
}
- [Theory(Skip = "DateTimeOffsets are not handled well in the uri parser")]
+ [Theory]
[InlineData("year(DiscontinuedOffset) eq 100", "$it => $it.DiscontinuedOffset.Year == 100")]
[InlineData("month(DiscontinuedOffset) eq 100", "$it => $it.DiscontinuedOffset.Month == 100")]
[InlineData("day(DiscontinuedOffset) eq 100", "$it => $it.DiscontinuedOffset.Day == 100")]
@@ -1044,12 +1049,17 @@ public void DateSecond()
[InlineData("second(DiscontinuedOffset) eq 100", "$it => $it.DiscontinuedOffset.Second == 100")]
public void DateTimeOffsetFunctions(string filter, string expression)
{
- VerifyQueryDeserialization(
- filter,
- expression);
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following assert shows the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Throws<ODataException>(() => Bind(filter));
+
+ // TODO: DateTimeOffsets are not handled well in the uri parser
+ // The following call shows the behavior without the bug, and should be enabled once the bug is fixed.
+ //VerifyQueryDeserialization(filter, expression);
}
- [Theory(Skip = "Timespans are not handled well in the uri parser")]
+ [Theory]
[InlineData("years(DiscontinuedSince) eq 100", "$it => $it.DiscontinuedSince.Years == 100")]
[InlineData("months(DiscontinuedSince) eq 100", "$it => $it.DiscontinuedSince.Months == 100")]
[InlineData("days(DiscontinuedSince) eq 100", "$it => $it.DiscontinuedSince.Days == 100")]
@@ -1058,9 +1068,14 @@ public void DateTimeOffsetFunctions(string filter, string expression)
[InlineData("seconds(DiscontinuedSince) eq 100", "$it => $it.DiscontinuedSince.Seconds == 100")]
public void TimespanFunctions(string filter, string expression)
{
- VerifyQueryDeserialization(
- filter,
- expression);
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following assert shows the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Throws<ODataException>(() => Bind(filter));
+
+ // TODO: Timespans are not handled well in the uri parser
+ // The following call shows the behavior without the bug, and should be enabled once the bug is fixed.
+ //VerifyQueryDeserialization(filter, expression);
}
#endregion
@@ -1141,7 +1156,7 @@ public void DateTimeExpression(string clause, string expectedExpression)
Error.Format(expectedExpression, dateTime));
}
- [Theory(Skip = "No DateTimeOffset parsing in ODataUriParser")]
+ [Theory]
[InlineData("DateTimeOffsetProp eq datetimeoffset'2002-10-10T17:00:00Z'", "$it => ($it.DateTimeOffsetProp == {0})", 0)]
[InlineData("DateTimeOffsetProp ge datetimeoffset'2002-10-10T17:00:00Z'", "$it => ($it.DateTimeOffsetProp >= {0})", 0)]
[InlineData("DateTimeOffsetProp le datetimeoffset'2002-10-10T17:00:00-07:00'", "$it => ($it.DateTimeOffsetProp <= {0})", -7)]
@@ -1152,9 +1167,17 @@ public void DateTimeExpression(string clause, string expectedExpression)
public void DateTimeOffsetExpression(string clause, string expectedExpression, double offsetHours)
{
var dateTimeOffset = new DateTimeOffset(2002, 10, 10, 17, 0, 0, TimeSpan.FromHours(offsetHours));
- VerifyQueryDeserialization<DataTypes>(
- "" + clause,
- Error.Format(expectedExpression, dateTimeOffset));
+
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following assert shows the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Throws<ODataException>(() => Bind("" + clause));
+
+ // TODO: No DateTimeOffset parsing in ODataUriParser
+ // The following call shows the behavior without the bug, and should be enabled once the bug is fixed.
+ //VerifyQueryDeserialization<DataTypes>(
+ // "" + clause,
+ // Error.Format(expectedExpression, dateTimeOffset));
}
[Fact]
@@ -234,7 +234,7 @@ public void GetQueryNodeParsesQuery()
Assert.Equal("Name", propertyAccessNode.Property.Name);
}
- [Fact(Skip="Enable once Uri Parser sets parameters of Any/All bound to CollectionProperty correctly")]
+ [Fact]
public void CanConstructValidAnyQueryOverPrimitiveCollectionProperty()
{
var model = new ODataModelBuilder().Add_Customer_EntityType_With_CollectionProperties().Add_Customers_EntitySet().GetEdmModel();
@@ -246,11 +246,20 @@ public void CanConstructValidAnyQueryOverPrimitiveCollectionProperty()
var aParameterType = aParameter.ParameterType.Definition as IEdmPrimitiveType;
Assert.NotNull(aParameter);
- Assert.NotNull(aParameterType);
- Assert.Equal("String", aParameter.Name);
+
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following asserts show the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Null(aParameterType);
+ Assert.Equal("a", aParameter.Name);
+
+ // TODO: Enable once Uri Parser sets parameters of Any/All bound to CollectionProperty correctly
+ // The following asserts show the behavior without the bug, and should be enabled once the bug is fixed.
+ //Assert.NotNull(aParameterType);
+ //Assert.Equal("Address", aParameter.Name);
}
- [Fact(Skip = "Enable once Uri Parser sets parameters of Any/All bound to CollectionProperty correctly")]
+ [Fact]
public void CanConstructValidAnyQueryOverComplexCollectionProperty()
{
var model = new ODataModelBuilder().Add_Customer_EntityType_With_CollectionProperties().Add_Customers_EntitySet().Add_Address_ComplexType().GetEdmModel();
@@ -262,8 +271,17 @@ public void CanConstructValidAnyQueryOverComplexCollectionProperty()
var aParameterType = aParameter.ParameterType.Definition as IEdmComplexType;
Assert.NotNull(aParameter);
- Assert.NotNull(aParameterType);
- Assert.Equal("Address", aParameter.Name);
+
+ // There's currently a bug here. For now, the test checks for the presence of the bug (as a reminder to fix
+ // the test once the bug is fixed).
+ // The following asserts show the behavior with the bug and should be removed once the bug is fixed.
+ Assert.Null(aParameterType);
+ Assert.Equal("a", aParameter.Name);
+
+ // TODO: Enable once Uri Parser sets parameters of Any/All bound to CollectionProperty correctly
+ // The following asserts show the behavior without the bug, and should be enabled once the bug is fixed.
+ //Assert.NotNull(aParameterType);
+ //Assert.Equal("Address", aParameter.Name);
}
[Fact]

0 comments on commit 015557d

Please sign in to comment.