Permalink
Browse files

Use Should.Fluent for assertions.

  • Loading branch information...
1 parent 6527ef8 commit d34993a656c2655ff690eaacb57b81e490861b84 @GraemeF committed Feb 16, 2011
Showing with 132 additions and 83 deletions.
  1. +3 −0 Twidder.Core.Tests/Twidder.Core.Tests.csproj
  2. +4 −2 Twidder.Core.Tests/TwitterCredentialsTests.cs
  3. +1 −0 Twidder.Core.Tests/packages.config
  4. +2 −5 Twiddler.AcceptanceTests/AuthorizationStepDefinitions.cs
  5. +6 −4 Twiddler.Tests/Commands/ArchiveTweetCommandTests.cs
  6. +5 −3 Twiddler.Tests/Commands/DeauthorizeCommandTests.cs
  7. +6 −4 Twiddler.Tests/Commands/MarkTweetAsReadCommandTests.cs
  8. +6 −4 Twiddler.Tests/Screens/ImageThumbnailScreenTests.cs
  9. +1 −1 Twiddler.Tests/Screens/LoadingTweetScreenTests.cs
  10. +12 −8 Twiddler.Tests/Screens/RequestMeterScreenTests.cs
  11. +4 −2 Twiddler.Tests/Screens/ShellScreenTests.cs
  12. +7 −5 Twiddler.Tests/Screens/StatusScreenTests.cs
  13. +4 −2 Twiddler.Tests/Screens/TimelineScreenTests.cs
  14. +17 −15 Twiddler.Tests/Screens/TweetScreenTests.cs
  15. +6 −5 Twiddler.Tests/Services/ImageServices/TwitPicDecoderTests.cs
  16. +7 −6 Twiddler.Tests/Services/ImageServices/YFrogDecoderTests.cs
  17. +4 −2 Twiddler.Tests/Services/LinkThumbnailScreenFactoryTests.cs
  18. +4 −2 Twiddler.Tests/Services/MemoryTweetStoreTests.cs
  19. +2 −2 Twiddler.Tests/Services/StoreTimelineTests.cs
  20. +5 −3 Twiddler.Tests/Services/TweetRatingTests.cs
  21. +5 −3 Twiddler.TweetSharp.Tests/AuthorizeCommandTests.cs
  22. +3 −0 Twiddler.TweetSharp.Tests/Twiddler.TweetSharp.Tests.csproj
  23. +3 −1 Twiddler.TweetSharp.Tests/TwitterClientTests.cs
  24. +1 −0 Twiddler.TweetSharp.Tests/packages.config
  25. +4 −2 Twiddler.TwitterStore.Tests/CredentialsDocumentStoreTests.cs
  26. +3 −1 Twiddler.TwitterStore.Tests/TweetTests.cs
  27. +3 −0 Twiddler.TwitterStore.Tests/Twiddler.TwitterStore.Tests.csproj
  28. +3 −1 Twiddler.TwitterStore.Tests/TwitterDocumentStoreTests.cs
  29. +1 −0 Twiddler.TwitterStore.Tests/packages.config
@@ -31,6 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Should.Fluent">
+ <HintPath>..\packages\ShouldFluent.1.1.12.0\lib\Should.Fluent.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -2,6 +2,8 @@
{
#region Using Directives
+ using Should.Fluent;
+
using Twiddler.Core.Models;
using Xunit;
@@ -14,14 +16,14 @@ public class TwitterCredentialsTests
public void GettingAreValid_WhenAccessTokenIsMissing_ReturnsFalse()
{
var test = new AccessToken("id", string.Empty, "accessTokenSecret");
- Assert.False(test.IsValid);
+ test.IsValid.Should().Be.False();
}
[Fact]
public void GettingAreValid_WhenCredentialsAreComplete_ReturnsTrue()
{
var test = new AccessToken("id", "accessToken", "accessTokenSecret");
- Assert.True(test.IsValid);
+ test.IsValid.Should().Be.True();
}
}
}
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="1.7.0.1540" />
+ <package id="ShouldFluent" version="1.1.12.0" />
</packages>
@@ -2,9 +2,6 @@
{
#region Using Directives
- using System;
-
- using Should.Core.Assertions;
using Should.Fluent;
using TechTalk.SpecFlow;
@@ -36,13 +33,13 @@ public void ThenAuthorizationShouldFail()
[Then(@"I should be authorized")]
public void ThenIShouldBeAuthorized()
{
- Assert.Equal("Authorized", Application.AuthorizationStatus, StringComparer.CurrentCultureIgnoreCase);
+ Application.AuthorizationStatus.Should().Equal("Authorized");
}
[Then(@"I should be unauthorized")]
public void ThenIShouldBeUnuathorized()
{
- Assert.Equal("Unauthorized", Application.AuthorizationStatus, StringComparer.CurrentCultureIgnoreCase);
+ Application.AuthorizationStatus.Should().Equal("Unauthorized");
}
[When(@"I authorize with Twitter")]
@@ -2,6 +2,8 @@
{
#region Using Directives
+ using Should.Fluent;
+
using Twiddler.Commands;
using Twiddler.Core.Models;
using Twiddler.TestData;
@@ -23,23 +25,23 @@ public void CanExecuteChanged_WhenTweetBecomesArchived_IsRaised()
tweet.Archive();
- Assert.True(eventRaised);
+ eventRaised.Should().Be.True();
}
[Fact]
public void CanExecute_WhenTweetIsArchived_IsFalse()
{
var test = new ArchiveTweetCommand(A.Tweet.Build());
- Assert.True(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.True();
}
[Fact]
public void CanExecute_WhenTweetIsNotArchived_IsTrue()
{
var test = new ArchiveTweetCommand(A.Tweet.Build());
- Assert.True(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.True();
}
[Fact]
@@ -50,7 +52,7 @@ public void Execute_WhenTweetIsNotArchived_ArchivesTweet()
test.Execute(null);
- Assert.True(tweet.IsArchived);
+ tweet.IsArchived.Should().Be.True();
}
}
}
@@ -6,6 +6,8 @@ namespace Twiddler.Tests.Commands
using NSubstitute;
+ using Should.Fluent;
+
using Twiddler.Commands;
using Twiddler.Core.Services;
@@ -30,7 +32,7 @@ public void CanExecuteChanged_WhenAuthorizationStatusChanges_IsRaised()
ClientAuthorizationStatusChangesTo(AuthorizationStatus.Verifying);
GC.KeepAlive(test);
- Assert.True(eventRaised);
+ eventRaised.Should().Be.True();
}
[Fact]
@@ -40,7 +42,7 @@ public void CanExecute_WhenAuthorized_ReturnsTrue()
ClientAuthorizationStatusChangesTo(AuthorizationStatus.Authorized);
- Assert.True(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.True();
}
[Theory]
@@ -54,7 +56,7 @@ public void CanExecute_WhenNotAuthorized_ReturnsFalse(AuthorizationStatus status
ClientAuthorizationStatusChangesTo(status);
- Assert.False(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.False();
}
[Fact]
@@ -4,6 +4,8 @@
using NSubstitute;
+ using Should.Fluent;
+
using Twiddler.Commands;
using Twiddler.Core.Models;
using Twiddler.Core.Services;
@@ -29,23 +31,23 @@ public void CanExecuteChanged_WhenTweetBecomesRead_IsRaised()
_tweet.MarkAsRead();
- Assert.True(eventRaised);
+ eventRaised.Should().Be.True();
}
[Fact]
public void CanExecute_WhenTweetIsNotRead_IsTrue()
{
MarkTweetAsReadCommand test = BuildDefaultTestSubject();
- Assert.True(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.True();
}
[Fact]
public void CanExecute_WhenTweetIsRead_IsFalse()
{
MarkTweetAsReadCommand test = BuildDefaultTestSubject();
- Assert.True(test.CanExecute(null));
+ test.CanExecute(null).Should().Be.True();
}
[Fact]
@@ -55,7 +57,7 @@ public void Execute_WhenTweetIsNotRead_MarksTweetAsRead()
test.Execute(null);
- Assert.True(_tweet.IsRead);
+ _tweet.IsRead.Should().Be.True();
}
[Fact]
@@ -6,6 +6,8 @@
using NSubstitute;
+ using Should.Fluent;
+
using Twiddler.Commands.Interfaces;
using Twiddler.Models;
using Twiddler.Screens;
@@ -30,31 +32,31 @@ public void GettingFullSize__ReturnsFullSizeFromLocations()
{
ImageThumbnailScreen test = BuildDefaultTestSubject();
- Assert.Equal(_imageLocations.FullSize, test.FullSize);
+ test.FullSize.Should().Equal(_imageLocations.FullSize);
}
[Fact]
public void GettingLink__ReturnsLinkFromLocations()
{
ImageThumbnailScreen test = BuildDefaultTestSubject();
- Assert.Equal(_imageLocations.Link, test.Link);
+ test.Link.Should().Equal(_imageLocations.Link);
}
[Fact]
public void GettingOpenCommand__ReturnsCommand()
{
ImageThumbnailScreen test = BuildDefaultTestSubject();
- Assert.Same(_openLinkCommand, test.OpenLinkCommand);
+ test.OpenLinkCommand.Should().Be.SameAs(_openLinkCommand);
}
[Fact]
public void GettingThumbnail__ReturnsThumbnailFromLocations()
{
ImageThumbnailScreen test = BuildDefaultTestSubject();
- Assert.Equal(_imageLocations.Thumbnail, test.Thumbnail);
+ test.Thumbnail.Should().Equal(_imageLocations.Thumbnail);
}
private ImageThumbnailScreen BuildDefaultTestSubject()
@@ -44,7 +44,7 @@ public void GettingId__ReturnsTweetId()
{
LoadingTweetScreen test = BuildDefaultTestSubject();
- Assert.Equal(_tweet.Id, test.Id);
+ test.Id.Should().Equal(_tweet.Id);
}
[Fact]
@@ -9,6 +9,9 @@
using NSubstitute;
+ using Should.Core.Exceptions;
+ using Should.Fluent;
+
using Twiddler.Screens;
using Twiddler.Services.Interfaces;
@@ -39,7 +42,7 @@ public void GettingHourlyLimit__GetsHourlyLimitFromLimitStatus()
const int hourlyLimit = 350;
_requestStatus.HourlyLimit = hourlyLimit;
- Assert.Equal(hourlyLimit, test.HourlyLimit);
+ test.HourlyLimit.Should().Equal(hourlyLimit);
}
[Fact]
@@ -51,7 +54,7 @@ public void GettingPeriodDuration__GetsFormattedPeriodDurationFromLimitStatus()
RequestMeterScreen test = BuildDefaultTestSubject();
test.Initialize();
- Assert.Equal("83m", test.PeriodDuration);
+ test.PeriodDuration.Should().Equal("83m");
}
[Fact]
@@ -62,7 +65,7 @@ public void GettingRemainingHits__GetsRemainingHitsFromLimitStatus()
const int remainingHits = 33;
_requestStatus.RemainingHits = remainingHits;
- Assert.Equal(remainingHits, test.RemainingHits);
+ test.RemainingHits.Should().Equal(remainingHits);
}
[Fact]
@@ -73,7 +76,7 @@ public void GettingRemainingTime_WhenClockHasPassedTheEndTime_ReturnsZero()
RequestMeterScreen test = BuildDefaultTestSubject();
test.Initialize();
- Assert.Equal("0m", test.RemainingTime);
+ test.RemainingTime.Should().Equal("0m");
}
[Fact]
@@ -84,7 +87,7 @@ public void GettingRemainingTime__GetsFormattedRemainingTimeFromLimitStatus()
RequestMeterScreen test = BuildDefaultTestSubject();
test.Initialize();
- Assert.Equal("5m", test.RemainingTime);
+ test.RemainingTime.Should().Equal("5m");
}
[Theory]
@@ -101,7 +104,7 @@ public void GettingUsedHitsFraction__ReturnsFractionOfHourlyLimit(int remainingH
_requestStatus.RemainingHits = remainingHits;
_requestStatus.HourlyLimit = 100;
- Assert.Equal(fraction, test.UsedHitsFraction);
+ test.UsedHitsFraction.Should().Equal(fraction);
}
[Theory]
@@ -117,7 +120,7 @@ public void GettingUsedTimeFraction__ReturnsFractionOfPeriodDuration(int remaini
TimeLeftInPeriodIs(TimeSpan.FromMinutes(remainingMinutes));
- Assert.Equal(fraction, test.UsedTimeFraction);
+ test.UsedTimeFraction.Should().Equal(fraction);
}
[Fact]
@@ -150,7 +153,8 @@ public void Shutdown__UnsubscribesFromRequestStatusChanges()
test.Initialize();
test.Shutdown();
- test.PropertyChanged += (sender, args) => Assert.True(false);
+ test.PropertyChanged +=
+ (sender, args) => { throw new AssertException("No properties should have changed."); };
PropertyChangesOnRequestStatus("RemainingHits");
}
@@ -4,6 +4,8 @@
using NSubstitute;
+ using Should.Fluent;
+
using Twiddler.Screens;
using Twiddler.Screens.Interfaces;
using Twiddler.Services.Interfaces;
@@ -27,7 +29,7 @@ public void GettingStatus_WhenInitialized_ReturnsInitializedStatus()
test.Initialize();
_status.Received().Initialize();
- Assert.Same(_status, test.Status);
+ test.Status.Should().Be.SameAs(_status);
}
[Fact]
@@ -37,7 +39,7 @@ public void GettingTimeline_WhenInitialized_ReturnsInitializedTimeline()
test.Initialize();
_timeline.Received().Initialize();
- Assert.Same(_timeline, test.Timeline);
+ test.Timeline.Should().Be.SameAs(_timeline);
}
[Fact]
Oops, something went wrong.

0 comments on commit d34993a

Please sign in to comment.