Skip to content
Browse files

- WIP: Refactoring code to RavenDb v2.0.

  • Loading branch information...
1 parent f32b755 commit b534abedeeb07b7a4e9009416f1387b3e5c4ee32 @PureKrome committed Apr 2, 2013
View
10 .gitignore
@@ -23,13 +23,15 @@
obj/
[Rr]elease*/
_ReSharper*/
-[Tt]humbs.db
-[Tt]est[Rr]esult*
-[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
*.resharper*
AppData/
+App_Data/
*.log.*
[Ll]ogs/
[Dd]ata/
-[Pp]ackages/
+[Pp]ackages/
+[Tt]humbs.db
+[Tt]est[Rr]esult*
+[Bb]uild[Ll]og.*
+*.sln.DotSettings.*
View
13 Code/RavenOverflow.Core/RavenOverflow.Core.csproj
@@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RavenOverflow.Core</RootNamespace>
<AssemblyName>RavenOverflow.Core</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\RavenOverflow\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,15 +33,16 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Raven.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Abstractions, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Abstractions.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Abstractions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.Lightweight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Client.Lightweight, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Client.Lightweight.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
View
2 Code/RavenOverflow.Core/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="RavenDB.Client" version="2.0.2261" targetFramework="net40" />
+ <package id="RavenDB.Client" version="2.0.2330" targetFramework="net40" />
</packages>
View
276 Code/RavenOverflow.FakeData/FakeQuestions.cs
@@ -11,31 +11,27 @@ namespace RavenOverflow.FakeData
public static class FakeQuestions
{
private static readonly IList<string> FakeTags = new List<string>
- {
- "ravendb",
- "asp.net-mvc",
- "c#",
- "linq",
- "moq",
- ".net",
- ".net3.5",
- "elmah",
- "yui-compressor",
- "minify",
- "mono",
- "asp.net-mvc3",
- "ruby-on-rails",
- "elmah",
- "rubygems",
- "pew-pew"
- };
-
- public static ICollection<Question> CreateFakeQuestions(IList<string> userIds)
{
- return CreateFakeQuestions(userIds, GetRandom.Int(20, 100));
- }
+ "ravendb",
+ "asp.net-mvc",
+ "c#",
+ "linq",
+ "moq",
+ ".net",
+ ".net3.5",
+ "elmah",
+ "yui-compressor",
+ "minify",
+ "mono",
+ "asp.net-mvc3",
+ "ruby-on-rails",
+ "elmah",
+ "rubygems",
+ "pew-pew"
+ };
- public static ICollection<Question> CreateFakeQuestions(IList<string> userIds, int numberOfFakeQuestions)
+ public static ICollection<Question> CreateFakeQuestions(IList<string> userIds = null,
+ int numberOfFakeQuestions = 50)
{
Condition.Requires(numberOfFakeQuestions).IsGreaterOrEqual(5); // First 5 questions are fixed.
@@ -68,8 +64,8 @@ public static Question CreateAFakeQuestion(string userId, IList<string> answerUs
.With(x => x.Subject = GetRandom.Phrase(GetRandom.Int(10, 50)))
.With(x => x.Content = GetRandom.Phrase(GetRandom.Int(30, 500)))
.And(x => x.CreatedByUserId = userId)
- .And(x => x.CreatedOn = GetRandom.DateTime(DateTime.UtcNow.AddMonths(-1),
- DateTime.UtcNow.AddMinutes(-5)))
+ .And(x => x.CreatedOn = GetRandom.DateTime(DateTime.UtcNow.AddMonths(-1),
+ DateTime.UtcNow.AddMinutes(-5)))
.And(x => x.NumberOfViews = GetRandom.PositiveInt(10000))
.And(x => x.Tags = FakeTags.ToRandomList(GetRandom.Int(1, 5)))
.And(x => x.Vote = CreateAFakeVote())
@@ -143,121 +139,121 @@ private static IList<Question> CreateFixedFakeQuestions(IList<string> userIds)
Condition.Requires(userIds).IsNotNull().IsLongerOrEqual(1);
return new List<Question>
- {
- new Question
- {
- Subject = "How to query nested information in RavenDB?",
- Content =
- "I have the following document called Reservation: { \"CustomerId\": 1, \"Items\": [ { \"EmployeeId\": \"employees/1\", \"StartTime\": ...",
- CreatedOn = DateTime.UtcNow.AddMinutes(5),
- Tags = new List<string> {"ravendb", ".net", "c#"},
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- NumberOfViews = 50,
- Vote = new Vote {DownVoteCount = 5, UpVoteCount = 10, FavoriteCount = 6},
- Comments = new List<Comment>
- {
- new Comment
- {
- Content = "Some comment 1",
- CreatedByUserId =
- userIds.ToRandomList(1).Single(),
- CreatedOn = DateTime.UtcNow.AddMinutes(2),
- UpVoteCount = 2
- },
- new Comment
- {
- Content = "Some comment 2",
- CreatedByUserId =
- userIds.ToRandomList(1).Single(),
- CreatedOn = DateTime.UtcNow.AddMinutes(1),
- }
- },
- Answers = new List<Answer>
- {
- new Answer
- {
- Content = "Answer 1 - blah blah blah",
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- CreatedOn = DateTime.UtcNow.AddMinutes(3),
- Vote = new Vote
- {
- DownVoteCount = 5,
- UpVoteCount = 10,
- FavoriteCount = 6
- }
- },
- new Answer
- {
- Content = "Answer 2 - blah blah blah",
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- CreatedOn = DateTime.UtcNow.AddMinutes(2),
- Vote = new Vote
- {
- DownVoteCount = 4,
- UpVoteCount = 8,
- FavoriteCount = 5
- }
- },
- new Answer
- {
- Content = "Answer 3 - blah blah blah",
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- CreatedOn = DateTime.UtcNow.AddMinutes(1),
- Vote = new Vote
- {
- DownVoteCount = 3,
- UpVoteCount = 6,
- FavoriteCount = 4
- }
- }
- }
- },
- new Question
- {
- Subject = "RavenDb MapReduce over subset of Data",
- Content =
- "Say I have the given document structure in RavenDb public class Car { public string Manufacturer {get;set;} public int BuildYear {get;set;} public string Colour {get;set;} public",
- CreatedOn = DateTime.UtcNow.AddMinutes(4),
- Tags = new List<string> {"ravendb", ".net", "c#"},
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- NumberOfViews = 44,
- Vote = new Vote {DownVoteCount = 4, UpVoteCount = 8, FavoriteCount = 5}
- },
- new Question
- {
- Subject = "RavenDB - retrieving part of document",
- Content =
- "I am playing with Raven DB for few days and I would like to use it as a storage for my Web chat application. I have document which contains some user data and chat history - which is big collection",
- CreatedOn = DateTime.UtcNow.AddMinutes(3),
- Tags = new List<string> {"ravendb", ".net", "c#"},
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- NumberOfViews = 33,
- Vote = new Vote {DownVoteCount = 3, UpVoteCount = 6, FavoriteCount = 4}
- },
- new Question
- {
- Subject = "RavenDB Index on SubClasses",
- Content =
- "I am trying to create an indexes for ProviderProfileId, Email, and Address1 I have created queries that work, but not indexes. I know the inheriting from List for the collections might be part of",
- CreatedOn = DateTime.UtcNow.AddMinutes(2),
- Tags = new List<string> {"ravendb", ".net", "c#"},
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- NumberOfViews = 22,
- Vote = new Vote {DownVoteCount = 2, UpVoteCount = 4, FavoriteCount = 3}
- },
- new Question
- {
- Subject =
- "given a list of objects using C# push them to ravendb without knowing which ones already exist",
- Content =
- "Given 1000 documents with a complex data structure. for e.g. a Car class that has three properties, Make and Model and one Id property. What is the most efficient way in C# to push these documents to",
- CreatedOn = DateTime.UtcNow.AddMinutes(1),
- Tags = new List<string> {"ravendb", ".net", "c#"},
- CreatedByUserId = userIds.ToRandomList(1).Single(),
- NumberOfViews = 11,
- Vote = new Vote {DownVoteCount = 1, UpVoteCount = 2, FavoriteCount = 2}
- }
- };
+ {
+ new Question
+ {
+ Subject = "How to query nested information in RavenDB?",
+ Content =
+ "I have the following document called Reservation: { \"CustomerId\": 1, \"Items\": [ { \"EmployeeId\": \"employees/1\", \"StartTime\": ...",
+ CreatedOn = DateTime.UtcNow.AddMinutes(5),
+ Tags = new List<string> {"ravendb", ".net", "c#"},
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ NumberOfViews = 50,
+ Vote = new Vote {DownVoteCount = 5, UpVoteCount = 10, FavoriteCount = 6},
+ Comments = new List<Comment>
+ {
+ new Comment
+ {
+ Content = "Some comment 1",
+ CreatedByUserId =
+ userIds.ToRandomList(1).Single(),
+ CreatedOn = DateTime.UtcNow.AddMinutes(2),
+ UpVoteCount = 2
+ },
+ new Comment
+ {
+ Content = "Some comment 2",
+ CreatedByUserId =
+ userIds.ToRandomList(1).Single(),
+ CreatedOn = DateTime.UtcNow.AddMinutes(1),
+ }
+ },
+ Answers = new List<Answer>
+ {
+ new Answer
+ {
+ Content = "Answer 1 - blah blah blah",
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ CreatedOn = DateTime.UtcNow.AddMinutes(3),
+ Vote = new Vote
+ {
+ DownVoteCount = 5,
+ UpVoteCount = 10,
+ FavoriteCount = 6
+ }
+ },
+ new Answer
+ {
+ Content = "Answer 2 - blah blah blah",
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ CreatedOn = DateTime.UtcNow.AddMinutes(2),
+ Vote = new Vote
+ {
+ DownVoteCount = 4,
+ UpVoteCount = 8,
+ FavoriteCount = 5
+ }
+ },
+ new Answer
+ {
+ Content = "Answer 3 - blah blah blah",
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ CreatedOn = DateTime.UtcNow.AddMinutes(1),
+ Vote = new Vote
+ {
+ DownVoteCount = 3,
+ UpVoteCount = 6,
+ FavoriteCount = 4
+ }
+ }
+ }
+ },
+ new Question
+ {
+ Subject = "RavenDb MapReduce over subset of Data",
+ Content =
+ "Say I have the given document structure in RavenDb public class Car { public string Manufacturer {get;set;} public int BuildYear {get;set;} public string Colour {get;set;} public",
+ CreatedOn = DateTime.UtcNow.AddMinutes(4),
+ Tags = new List<string> {"ravendb", ".net", "c#"},
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ NumberOfViews = 44,
+ Vote = new Vote {DownVoteCount = 4, UpVoteCount = 8, FavoriteCount = 5}
+ },
+ new Question
+ {
+ Subject = "RavenDB - retrieving part of document",
+ Content =
+ "I am playing with Raven DB for few days and I would like to use it as a storage for my Web chat application. I have document which contains some user data and chat history - which is big collection",
+ CreatedOn = DateTime.UtcNow.AddMinutes(3),
+ Tags = new List<string> {"ravendb", ".net", "c#"},
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ NumberOfViews = 33,
+ Vote = new Vote {DownVoteCount = 3, UpVoteCount = 6, FavoriteCount = 4}
+ },
+ new Question
+ {
+ Subject = "RavenDB Index on SubClasses",
+ Content =
+ "I am trying to create an indexes for ProviderProfileId, Email, and Address1 I have created queries that work, but not indexes. I know the inheriting from List for the collections might be part of",
+ CreatedOn = DateTime.UtcNow.AddMinutes(2),
+ Tags = new List<string> {"ravendb", ".net", "c#"},
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ NumberOfViews = 22,
+ Vote = new Vote {DownVoteCount = 2, UpVoteCount = 4, FavoriteCount = 3}
+ },
+ new Question
+ {
+ Subject =
+ "given a list of objects using C# push them to ravendb without knowing which ones already exist",
+ Content =
+ "Given 1000 documents with a complex data structure. for e.g. a Car class that has three properties, Make and Model and one Id property. What is the most efficient way in C# to push these documents to",
+ CreatedOn = DateTime.UtcNow.AddMinutes(1),
+ Tags = new List<string> {"ravendb", ".net", "c#"},
+ CreatedByUserId = userIds.ToRandomList(1).Single(),
+ NumberOfViews = 11,
+ Vote = new Vote {DownVoteCount = 1, UpVoteCount = 2, FavoriteCount = 2}
+ }
+ };
}
}
}
View
7 Code/RavenOverflow.FakeData/FakeUsers.cs
@@ -23,12 +23,7 @@ public static User CreateAFakeUser()
.Build();
}
- public static ICollection<User> CreateFakeUsers()
- {
- return CreateFakeUsers(GetRandom.Int(20, 100));
- }
-
- public static ICollection<User> CreateFakeUsers(int numberOfFakeUsers)
+ public static ICollection<User> CreateFakeUsers(int numberOfFakeUsers = 20)
{
var fixedUsers = CreateFixedFakeUsers();
Condition.Requires(numberOfFakeUsers).IsNotLessThan(fixedUsers.Count);
View
5 Code/RavenOverflow.FakeData/RavenOverflow.FakeData.csproj
@@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RavenOverflow.FakeData</RootNamespace>
<AssemblyName>RavenOverflow.FakeData</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\RavenOverflow\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CuttingEdge.Conditions">
View
13 Code/RavenOverflow.Services/RavenOverflow.Services.csproj
@@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RavenOverflow.Services</RootNamespace>
<AssemblyName>RavenOverflow.Services</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\RavenOverflow\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoMapper, Version=2.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
@@ -40,13 +43,13 @@
<Reference Include="CuttingEdge.Conditions">
<HintPath>..\..\packages\CuttingEdge.Conditions.1.2.0.0\lib\NET35\CuttingEdge.Conditions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Abstractions, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Abstractions.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Abstractions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.Lightweight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Client.Lightweight, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Client.Lightweight.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
View
23 Code/RavenOverflow.Services/UserService.cs
@@ -7,25 +7,25 @@
namespace RavenOverflow.Services
{
- public class UserService : IUserService
+ public class UserService : RavenDbBaseService, IUserService
{
- private readonly IDocumentSession _documentSession;
-
- public UserService(IDocumentSession documentSession)
+ public UserService(IDocumentSession documentSession) : base(documentSession)
{
- _documentSession = documentSession;
}
#region IUserService Members
public User CreateOrUpdate(OAuthData oAuthData, string userName, string fullName, string email)
{
// Lets find an existing user for the provider OR the email address if the provider doesn't exist.
- User user =
- _documentSession.Query<User>()
- .SingleOrDefault(x =>
- x.OAuthData.Any(y => y.Id == oAuthData.Id && y.OAuthProvider == oAuthData.OAuthProvider)) ??
- _documentSession.Query<User>().SingleOrDefault(x => x.Email == email);
+ User user = DocumentSession
+ .Query<User>()
+ .SingleOrDefault(x =>
+ x.OAuthData.Any(y => y.Id == oAuthData.Id &&
+ y.OAuthProvider == oAuthData.OAuthProvider)) ??
+ DocumentSession
+ .Query<User>()
+ .SingleOrDefault(x => x.Email == email);
if (user != null)
{
@@ -63,8 +63,7 @@ public User CreateOrUpdate(OAuthData oAuthData, string userName, string fullName
user.OAuthData.Add(oAuthData);
}
- _documentSession.Store(user);
- _documentSession.SaveChanges();
+ DocumentSession.Store(user);
return user;
}
View
2 Code/RavenOverflow.Services/packages.config
@@ -2,5 +2,5 @@
<packages>
<package id="AutoMapper" version="2.2.1" targetFramework="net40" />
<package id="CuttingEdge.Conditions" version="1.2.0.0" />
- <package id="RavenDB.Client" version="2.0.2261" targetFramework="net40" />
+ <package id="RavenDB.Client" version="2.0.2330" targetFramework="net40" />
</packages>
View
2 Code/RavenOverflow.Tests/Controllers/ControllerUtilities.cs
@@ -1,7 +1,6 @@
using System.Web.Mvc;
using CuttingEdge.Conditions;
using Moq;
-using RavenOverflow.Web.Models.Authentication;
namespace RavenOverflow.Tests.Controllers
{
@@ -17,6 +16,7 @@ public static class ControllerUtilities
Condition.Requires(controller);
// Some fake Authentication stuff.
+ // TODO: Replace with CLAIMS.
var customIdentity = new CustomIdentity(userId, displayName);
var customPrincipal = new CustomPrincipal(customIdentity, roles);
View
452 Code/RavenOverflow.Tests/Controllers/HomeControllerFacts.cs
@@ -9,291 +9,315 @@
using RavenOverflow.Web.Controllers;
using RavenOverflow.Web.Models.ViewModels;
using RavenOverflow.Web.RavenDb.Indexes;
+using WorldDomination.Security;
using Xunit;
namespace RavenOverflow.Tests.Controllers
{
// ReSharper disable InconsistentNaming
public class HomeControllerFacts : RavenDbFactBase
- {
- public HomeControllerFacts()
+ {
+ public class IndexFacts : RavenDbFactBase
{
- // WebSite requires AutoMapper mappings.
- AutoMapperBootstrapper.ConfigureMappings();
- Mapper.AssertConfigurationIsValid();
- }
+ public IndexFacts()
+ {
+ // WebSite requires AutoMapper mappings.
+ AutoMapperBootstrapper.ConfigureMappings();
+ Mapper.AssertConfigurationIsValid();
+ }
- [Fact]
- public void GivenSomeQuestions_Index_ReturnsTheMostRecentQuestions()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
+ [Fact]
+ public void GivenSomeQuestions_Index_ReturnsTheMostRecentQuestions()
+ {
+ IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- // Arrange.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ // Arrange.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Act.
- var result = homeController.Index(null, null) as ViewResult;
+ // Act.
+ var result = homeController.Index(null, null) as ViewResult;
- // Assert.
- Assert.NotNull(result);
+ // Assert.
+ Assert.NotNull(result);
- var model = result.Model as IndexViewModel;
- Assert.NotNull(model);
- Assert.NotNull(model.QuestionListViewModel);
- Assert.NotNull(model.QuestionListViewModel.Questions);
- Assert.Equal(20, model.QuestionListViewModel.Questions.Count);
+ var model = result.Model as IndexViewModel;
+ Assert.NotNull(model);
+ Assert.NotNull(model.QuestionListViewModel);
+ Assert.NotNull(model.QuestionListViewModel.Questions);
+ Assert.Equal(20, model.QuestionListViewModel.Questions.Count);
- // Make sure all the items are ordered correctly.
- DateTime? previousQuestion = null;
- foreach (QuestionWithDisplayName question in model.QuestionListViewModel.Questions)
- {
- if (previousQuestion.HasValue)
+ // Make sure all the items are ordered correctly.
+ DateTime? previousQuestion = null;
+ foreach (QuestionWithDisplayName question in model.QuestionListViewModel.Questions)
{
- Assert.True(previousQuestion.Value >= question.CreatedOn);
+ if (previousQuestion.HasValue)
+ {
+ Assert.True(previousQuestion.Value >= question.CreatedOn);
+ }
+
+ previousQuestion = question.CreatedOn;
}
- previousQuestion = question.CreatedOn;
+ // Now lets test that our fixed questions come back correctly.
+ List<Question> fixedQuestions = FakeQuestions.CreateFakeQuestions(null, 5).ToList();
+ for (int i = 0; i < 5; i++)
+ {
+ // Can Assert anything except
+ // * Id (these new fakes haven't been Stored)
+ // * CreatedByUserId - this is randomized when fakes are created.
+ // * CreatedOn - these fakes were made AFTER the Stored data.
+ // ASSUMPTION: the first 5 fixed questions are the first 5 documents in the Document Store.
+ QuestionWithDisplayName question = model.QuestionListViewModel.Questions[i];
+ Assert.Equal(fixedQuestions[i].Subject, question.Subject);
+ Assert.Equal(fixedQuestions[i].Content, question.Content);
+ Assert.Equal(fixedQuestions[i].NumberOfViews, question.NumberOfViews);
+ Assert.Equal(fixedQuestions[i].Vote.DownVoteCount, question.Vote.DownVoteCount);
+ Assert.Equal(fixedQuestions[i].Vote.FavoriteCount, question.Vote.FavoriteCount);
+ Assert.Equal(fixedQuestions[i].Vote.UpVoteCount, question.Vote.UpVoteCount);
+ }
}
- // Now lets test that our fixed questions come back correctly.
- List<Question> fixedQuestions = FakeQuestions.CreateFakeQuestions(null, 5).ToList();
- for (int i = 0; i < 5; i++)
+ [Fact]
+ public void GivenSomeQuestions_Index_ReturnsTheMostRecentPopularTagsInTheLast30Days()
{
- // Can Assert anything except
- // * Id (these new fakes haven't been Stored)
- // * CreatedByUserId - this is randomized when fakes are created.
- // * CreatedOn - these fakes were made AFTER the Stored data.
- // ASSUMPTION: the first 5 fixed questions are the first 5 documents in the Document Store.
- QuestionWithDisplayName question = model.QuestionListViewModel.Questions[i];
- Assert.Equal(fixedQuestions[i].Subject, question.Subject);
- Assert.Equal(fixedQuestions[i].Content, question.Content);
- Assert.Equal(fixedQuestions[i].NumberOfViews, question.NumberOfViews);
- Assert.Equal(fixedQuestions[i].Vote.DownVoteCount, question.Vote.DownVoteCount);
- Assert.Equal(fixedQuestions[i].Vote.FavoriteCount, question.Vote.FavoriteCount);
- Assert.Equal(fixedQuestions[i].Vote.UpVoteCount, question.Vote.UpVoteCount);
- }
- }
-
- [Fact]
- public void GivenSomeQuestions_Index_ReturnsTheMostRecentPopularTagsInTheLast30Days()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
+ IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- // Arrange.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ // Arrange.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Act.
- var result = homeController.Index(null, null) as ViewResult;
+ // Act.
+ var result = homeController.Index(null, null) as ViewResult;
- // Assert.
- Assert.NotNull(result);
+ // Assert.
+ Assert.NotNull(result);
- var model = result.Model as IndexViewModel;
- Assert.NotNull(model);
+ var model = result.Model as IndexViewModel;
+ Assert.NotNull(model);
- Assert.NotNull(model.RecentPopularTags);
- Assert.True(model.RecentPopularTags.Count > 0);
+ Assert.NotNull(model.RecentPopularTags);
+ Assert.True(model.RecentPopularTags.Count > 0);
- // Make sure all the items are ordered correctly.
- int? previousCount = null;
- foreach (var keyValuePair in model.RecentPopularTags)
- {
- if (previousCount.HasValue)
+ // Make sure all the items are ordered correctly.
+ int? previousCount = null;
+ foreach (var keyValuePair in model.RecentPopularTags)
{
- Assert.True(previousCount.Value >= keyValuePair.Value);
- }
+ if (previousCount.HasValue)
+ {
+ Assert.True(previousCount.Value >= keyValuePair.Value);
+ }
- previousCount = keyValuePair.Value;
+ previousCount = keyValuePair.Value;
+ }
}
- }
- [Fact]
- public void GivenAnAuthenticatedUserWithSomeFavouriteTags_Index_ReturnsAFavouriteTagsViewModelWithContent()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
+ [Fact]
+ public void GivenNoAuthenticatedUser_Index_ReturnsFavouriteTagsViewModelWithNoTags()
+ {
+ IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- // Arrange.
- // Note: we're faking that a user has authenticated.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController, displayName: "Pure.Krome");
+ // Arrange.
+ // Note: we're faking that no user has been authenticated.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
+ // Act.
+ var result = homeController.Index(null, null) as ViewResult;
- // Act.
- var result = homeController.Index(null, null) as ViewResult;
+ // Assert.
+ Assert.NotNull(result);
- // Assert.
- Assert.NotNull(result);
+ var model = result.Model as IndexViewModel;
+ Assert.NotNull(model);
- var model = result.Model as IndexViewModel;
- Assert.NotNull(model);
+ UserTagListViewModel userFavoriteTagListViewModel = model.UserFavoriteTagListViewModel;
+ Assert.NotNull(userFavoriteTagListViewModel);
- UserTagListViewModel userFavoriteTagListViewModel = model.UserFavoriteTagListViewModel;
- Assert.NotNull(userFavoriteTagListViewModel);
+ Assert.Equal("Favorite Tags", userFavoriteTagListViewModel.Header);
+ Assert.Equal("interesting-tags", userFavoriteTagListViewModel.DivId1);
+ Assert.Equal("interestingtags", userFavoriteTagListViewModel.DivId2);
+ Assert.Null(userFavoriteTagListViewModel.Tags);
+ }
- Assert.Equal("Favorite Tags", userFavoriteTagListViewModel.Header);
- Assert.Equal("interesting-tags", userFavoriteTagListViewModel.DivId1);
- Assert.Equal("interestingtags", userFavoriteTagListViewModel.DivId2);
- Assert.NotNull(userFavoriteTagListViewModel.Tags);
- Assert.Equal(3, userFavoriteTagListViewModel.Tags.Count);
- }
+ [Fact]
+ public void GivenSomeQuestionsAndATag_Index_ReturnsAViewResult()
+ {
+ IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- [Fact]
- public void GivenNoAuthenticatedUser_Index_ReturnsFavouriteTagsViewModelWithNoTags()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
+ // Arrange.
+ const string tag = "ravendb";
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Arrange.
- // Note: we're faking that no user has been authenticated.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ // Act.
+ var result = homeController.Index(null, tag) as ViewResult;
- // Act.
- var result = homeController.Index(null, null) as ViewResult;
+ // Assert.
+ Assert.NotNull(result);
- // Assert.
- Assert.NotNull(result);
+ var model = result.Model as IndexViewModel;
+ Assert.NotNull(model);
+ Assert.NotNull(model.QuestionListViewModel);
+ Assert.NotNull(model.QuestionListViewModel.Questions);
- var model = result.Model as IndexViewModel;
- Assert.NotNull(model);
+ // Make sure each question is tagged with the defined tag-value.
+ Assert.True(model.QuestionListViewModel.Questions.All(x => x.Tags.Contains(tag)));
+ }
- UserTagListViewModel userFavoriteTagListViewModel = model.UserFavoriteTagListViewModel;
- Assert.NotNull(userFavoriteTagListViewModel);
+ [Fact]
+ public void GivenAnAuthenticatedUserWithSomeFavouriteTags_Index_ReturnsAFavouriteTagsViewModelWithContent()
+ {
+ IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- Assert.Equal("Favorite Tags", userFavoriteTagListViewModel.Header);
- Assert.Equal("interesting-tags", userFavoriteTagListViewModel.DivId1);
- Assert.Equal("interestingtags", userFavoriteTagListViewModel.DivId2);
- Assert.Null(userFavoriteTagListViewModel.Tags);
- }
+ // Arrange.
+ // Note: we're faking that a user has authenticated.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController, displayName: "Pure.Krome");
- [Fact]
- public void GivenSomeQuestionsAndNoDisplayNameAndNoTags_Index_ReturnsAJsonViewOfMostRecentQuestions()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search)};
- // Arrange.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ // Act.
+ var result = homeController.Index(null, null) as ViewResult;
- // Act.
- // Note: this should return a list of the 20 most recent.
- JsonResult result = homeController.IndexJson(null, null);
+ // Assert.
+ Assert.NotNull(result);
- // Assert.
- Assert.NotNull(result);
- var questions = result.Data as IList<QuestionWithDisplayName>;
- Assert.NotNull(questions);
- Assert.Equal(20, questions.Count);
+ var model = result.Model as IndexViewModel;
+ Assert.NotNull(model);
- // Now lets Make sure each one is ok.
- DateTime? previousDate = null;
- foreach (QuestionWithDisplayName question in questions)
- {
- if (previousDate.HasValue)
- {
- Assert.True(previousDate.Value > question.CreatedOn);
- }
+ UserTagListViewModel userFavoriteTagListViewModel = model.UserFavoriteTagListViewModel;
+ Assert.NotNull(userFavoriteTagListViewModel);
- previousDate = question.CreatedOn;
- Assert.NotNull(question.DisplayName);
- Assert.NotNull(question.Id);
- Assert.NotNull(question.CreatedByUserId);
- Assert.NotNull(question.Subject);
- Assert.NotNull(question.Content);
+ Assert.Equal("Favorite Tags", userFavoriteTagListViewModel.Header);
+ Assert.Equal("interesting-tags", userFavoriteTagListViewModel.DivId1);
+ Assert.Equal("interestingtags", userFavoriteTagListViewModel.DivId2);
+ Assert.NotNull(userFavoriteTagListViewModel.Tags);
+ Assert.Equal(3, userFavoriteTagListViewModel.Tags.Count);
}
- }
-
- [Fact]
- public void GivenSomeQuestionsAndATag_Index_ReturnsAViewResult()
- {
- IndexesToExecute = new List<Type> {typeof (Questions_Search), typeof (RecentPopularTags)};
- // Arrange.
- const string tag = "ravendb";
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ [Fact]
+ public void GivenSomeQuestionsAndNoDisplayNameAndNoTags_Index_ReturnsAJsonViewOfMostRecentQuestions()
+ {
+ IndexesToExecute = new List<Type> {typeof (Questions_Search)};
- // Act.
- var result = homeController.Index(null, tag) as ViewResult;
+ // Arrange.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Assert.
- Assert.NotNull(result);
+ // Act.
+ // Note: this should return a list of the 20 most recent.
+ JsonResult result = homeController.IndexJson(null, null);
- var model = result.Model as IndexViewModel;
- Assert.NotNull(model);
- Assert.NotNull(model.QuestionListViewModel);
- Assert.NotNull(model.QuestionListViewModel.Questions);
+ // Assert.
+ Assert.NotNull(result);
+ var questions = result.Data as IList<QuestionWithDisplayName>;
+ Assert.NotNull(questions);
+ Assert.Equal(20, questions.Count);
- // Make sure each question is tagged with the defined tag-value.
- Assert.True(model.QuestionListViewModel.Questions.All(x => x.Tags.Contains(tag)));
+ // Now lets Make sure each one is ok.
+ DateTime? previousDate = null;
+ foreach (QuestionWithDisplayName question in questions)
+ {
+ if (previousDate.HasValue)
+ {
+ Assert.True(previousDate.Value > question.CreatedOn);
+ }
+
+ previousDate = question.CreatedOn;
+ Assert.NotNull(question.DisplayName);
+ Assert.NotNull(question.Id);
+ Assert.NotNull(question.CreatedByUserId);
+ Assert.NotNull(question.Subject);
+ Assert.NotNull(question.Content);
+ }
+ }
}
- [Fact]
- public void GivenSomeQuestionsAndAnExistingTag_Tags_ReturnsAListOfTaggedQuestions()
+ public class TagsFacts : RavenDbFactBase
{
- // Arrange.
- const string tag = "ravendb";
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ public TagsFacts()
+ {
+ // WebSite requires AutoMapper mappings.
+ AutoMapperBootstrapper.ConfigureMappings();
+ Mapper.AssertConfigurationIsValid();
+ }
- // Act.
- var result = homeController.Tag(tag) as JsonResult;
+ [Fact]
+ public void GivenSomeQuestionsAndAnExistingTag_Tags_ReturnsAListOfTaggedQuestions()
+ {
+ // Arrange.
+ const string tag = "ravendb";
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Assert.
- Assert.NotNull(result);
+ // Act.
+ var result = homeController.Tag(tag) as JsonResult;
- dynamic model = result.Data;
- Assert.NotNull(model);
+ // Assert.
+ Assert.NotNull(result);
- // At least 5 questions are hardcoded to include the RavenDb tag.
- Assert.NotNull(model.Questions);
- Assert.True(model.Questions.Count >= 5);
- Assert.True(model.TotalResults >= 5);
- }
+ dynamic model = result.Data;
+ Assert.NotNull(model);
- [Fact]
- public void GivenSomeQuestionsAndAnExistingTag_Search_ReturnsAListOfTags()
- {
- IndexesToExecute = new List<Type> {typeof (RecentPopularTags)};
-
- // Arrange.
- const string tag = "ravendb";
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
-
- // Act.
- var result = homeController.Search(tag) as JsonResult;
-
- // Assert.
- Assert.NotNull(result);
- dynamic model = result.Data;
- Assert.NotNull(model);
- Assert.Equal(1, model.Count);
- Assert.Equal("ravendb", model[0]);
+ // At least 5 questions are hardcoded to include the RavenDb tag.
+ Assert.NotNull(model.Questions);
+ Assert.True(model.Questions.Count >= 5);
+ Assert.True(model.TotalResults >= 5);
+ }
}
- [Fact]
- public void GivenSomeQuestionsAndAnExistingPartialTag_Search_ReturnsAListOfTaggedQuestions()
+ public class SearchFacts : RavenDbFactBase
{
- IndexesToExecute = new List<Type> {typeof (RecentPopularTags)};
+ public SearchFacts()
+ {
+ // WebSite requires AutoMapper mappings.
+ AutoMapperBootstrapper.ConfigureMappings();
+ Mapper.AssertConfigurationIsValid();
+ }
- // Arrange.
- const string tag = "ravne"; // Hardcoded Typo.
- var homeController = new HomeController(DocumentSession);
- ControllerUtilities.SetUpControllerContext(homeController);
+ [Fact]
+ public void GivenSomeQuestionsAndAnExistingTag_Search_ReturnsAListOfTags()
+ {
+ IndexesToExecute = new List<Type> {typeof (RecentPopularTags)};
+
+ // Arrange.
+ const string tag = "ravendb";
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
+
+ // Act.
+ var result = homeController.Search(tag) as JsonResult;
+
+ // Assert.
+ Assert.NotNull(result);
+ dynamic model = result.Data;
+ Assert.NotNull(model);
+ Assert.Equal(1, model.Count);
+ Assert.Equal("ravendb", model[0]);
+ }
+
+ [Fact]
+ public void GivenSomeQuestionsAndAnExistingPartialTag_Search_ReturnsAListOfTaggedQuestions()
+ {
+ IndexesToExecute = new List<Type> {typeof (RecentPopularTags)};
+
+ // Arrange.
+ const string tag = "ravne"; // Hardcoded Typo.
+ var homeController = new HomeController(DocumentSession, new CustomFormsAuthentication());
+ ControllerUtilities.SetUpControllerContext(homeController);
- // Act.
- var result = homeController.Search(tag) as JsonResult;
+ // Act.
+ var result = homeController.Search(tag) as JsonResult;
- // Assert.
- Assert.NotNull(result);
+ // Assert.
+ Assert.NotNull(result);
- dynamic model = result.Data;
- Assert.NotNull(model);
- Assert.Equal(1, model.Count);
- Assert.Equal("ravendb", model[0]);
+ dynamic model = result.Data;
+ Assert.NotNull(model);
+ Assert.Equal(1, model.Count);
+ Assert.Equal("ravendb", model[0]);
+ }
}
}
View
5 Code/RavenOverflow.Tests/Controllers/QuestionControllerFacts.cs
@@ -1,12 +1,9 @@
using System.Web.Mvc;
using AutoMapper;
-using FizzWare.NBuilder;
-using RavenOverflow.Core.Services;
using RavenOverflow.Services;
using RavenOverflow.Web.Areas.Question.Controllers;
using RavenOverflow.Web.Areas.Question.Models;
using RavenOverflow.Web.AutoMapper;
-using RavenOverflow.Web.Models.Authentication;
using Xunit;
namespace RavenOverflow.Tests.Controllers
@@ -67,7 +64,7 @@ public void GivenAValidQuestionAndALoggedInUser_Create_AddsTheQuestionAndRedicec
var questionsController = new QuestionsController(DocumentSession, questionService);
ControllerUtilities.SetUpControllerContext(questionsController, "users/1");
var createInputModel =
- new QuestionInputModel()
+ new QuestionInputModel
{
Subject = "aaaad fdds fsd ds",
Content = "sdhfskfhksd sd",
View
16 Code/RavenOverflow.Tests/Controllers/UserControllerFacts.cs
@@ -1,19 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web.Mvc;
-using AutoMapper;
-using CuttingEdge.Conditions;
-using Moq;
-using Raven.Client;
-using RavenOverflow.Core.Entities;
-using RavenOverflow.FakeData;
+using AutoMapper;
using RavenOverflow.Web.AutoMapper;
-using RavenOverflow.Web.Controllers;
-using RavenOverflow.Web.Models;
-using RavenOverflow.Web.Models.Authentication;
-using RavenOverflow.Web.Models.ViewModels;
-using Xunit;
namespace RavenOverflow.Tests.Controllers
{
View
34 Code/RavenOverflow.Tests/RavenOverflow.Tests.csproj
@@ -10,10 +10,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RavenOverflow.Tests</RootNamespace>
<AssemblyName>RavenOverflow.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\RavenOverflow\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoMapper, Version=2.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
@@ -46,21 +49,17 @@
<Reference Include="Moq">
<HintPath>..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
- <Reference Include="Raven.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Abstractions.dll</HintPath>
+ <Reference Include="Raven.Abstractions">
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Abstractions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.Embedded, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Embedded.2.0.2261\lib\net40\Raven.Client.Embedded.dll</HintPath>
+ <Reference Include="Raven.Client.Embedded">
+ <HintPath>..\..\packages\RavenDB.Embedded.2.0.2330\lib\net40\Raven.Client.Embedded.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.Lightweight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Client.Lightweight.dll</HintPath>
+ <Reference Include="Raven.Client.Lightweight">
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
- <Reference Include="Raven.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Database.2.0.2261\lib\net40\Raven.Database.dll</HintPath>
+ <Reference Include="Raven.Database">
+ <HintPath>..\..\packages\RavenDB.Database.2.0.2330\lib\net40\Raven.Database.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
@@ -69,6 +68,15 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="WorldDomination.Raven.Client">
+ <HintPath>..\..\packages\WorldDomination.Raven.Client.0.3.3\lib\net40\WorldDomination.Raven.Client.dll</HintPath>
+ </Reference>
+ <Reference Include="WorldDomination.Raven.Tests.Helpers">
+ <HintPath>..\..\packages\WorldDomination.Raven.Tests.Helpers.0.3.3\lib\net40\WorldDomination.Raven.Tests.Helpers.dll</HintPath>
+ </Reference>
+ <Reference Include="WorldDomination.Security">
+ <HintPath>..\..\packages\WorldDomination.Security.0.4.0\lib\net45\WorldDomination.Security.dll</HintPath>
+ </Reference>
<Reference Include="xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
View
8 Code/RavenOverflow.Tests/packages.config
@@ -4,8 +4,10 @@
<package id="CuttingEdge.Conditions" version="1.2.0.0" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" />
- <package id="RavenDB.Client" version="2.0.2261" targetFramework="net40" />
- <package id="RavenDB.Database" version="2.0.2261" targetFramework="net40" />
- <package id="RavenDB.Embedded" version="2.0.2261" targetFramework="net40" />
+ <package id="RavenDB.Client" version="2.0.2330" targetFramework="net40" />
+ <package id="RavenDB.Database" version="2.0.2330" targetFramework="net40" />
+ <package id="RavenDB.Embedded" version="2.0.2330" targetFramework="net40" />
+ <package id="WorldDomination.Raven.Client" version="0.3.3" targetFramework="net45" />
+ <package id="WorldDomination.Raven.Tests.Helpers" version="0.3.3" targetFramework="net45" />
<package id="xunit" version="1.9.1" targetFramework="net40" />
</packages>
View
195 Code/RavenOverflow.Web/Controllers/HomeController.cs
@@ -19,7 +19,8 @@ public class HomeController : BaseController
{
private readonly ICustomFormsAuthentication _customFormsAuthentication;
- public HomeController(IDocumentSession documentSession, ICustomFormsAuthentication customCustomFormsAuthentication) : base(documentSession)
+ public HomeController(IDocumentSession documentSession,
+ ICustomFormsAuthentication customCustomFormsAuthentication) : base(documentSession)
{
Condition.Requires(customCustomFormsAuthentication).IsNotNull();
@@ -37,14 +38,14 @@ public ActionResult Authenticate()
};
_customFormsAuthentication.SignIn(userData);
- return RedirectToAction("Index", "Home", new { area = "" });
+ return RedirectToAction("Index", "Home", new {area = ""});
}
[HttpGet]
public ActionResult SignOut()
{
_customFormsAuthentication.SignOut();
- return RedirectToAction("Index", "Home", new { area = "" });
+ return RedirectToAction("Index", "Home", new {area = ""});
}
[HttpGet]
@@ -63,31 +64,31 @@ public ActionResult Index(string displayName, string tag)
IQueryable<User> userQuery = UserQuery(displayName);
var viewModel = new IndexViewModel(ClaimsUser)
- {
- Header = header,
- QuestionListViewModel = new QuestionListViewModel
- {
- Questions = questionsQuery.ToList()
- },
- RecentPopularTags = recentPopularTags.ToDictionary(x => x.Tag, x => x.Count),
- UserFavoriteTagListViewModel = new UserTagListViewModel
- {
- Header = "Favorite Tags",
- DivId1 = "interesting-tags",
- DivId2 = "interestingtags",
- Tags = userQuery == null
- ? null
- : (userQuery.SingleOrDefault() ??
- new User()).FavoriteTags
- },
- UserIgnoredTagList = new UserTagListViewModel
- {
- Header = "Ignored Tags",
- DivId1 = "ignored-tags",
- DivId2 = "ignoredtags",
- Tags = null
- }
- };
+ {
+ Header = header,
+ QuestionListViewModel = new QuestionListViewModel
+ {
+ Questions = questionsQuery.ToList()
+ },
+ RecentPopularTags = recentPopularTags.ToDictionary(x => x.Tag, x => x.Count),
+ UserFavoriteTagListViewModel = new UserTagListViewModel
+ {
+ Header = "Favorite Tags",
+ DivId1 = "interesting-tags",
+ DivId2 = "interestingtags",
+ Tags = userQuery == null
+ ? null
+ : (userQuery.SingleOrDefault() ??
+ new User()).FavoriteTags
+ },
+ UserIgnoredTagList = new UserTagListViewModel
+ {
+ Header = "Ignored Tags",
+ DivId1 = "ignored-tags",
+ DivId2 = "ignoredtags",
+ Tags = null
+ }
+ };
return View(viewModel);
}
@@ -109,32 +110,32 @@ public ActionResult BatchedIndex(string displayName, string tag)
Lazy<IEnumerable<User>> lazyUserQuery = (userQuery != null ? userQuery.Lazily() : null);
var viewModel = new IndexViewModel(ClaimsUser)
- {
- Header = header,
- QuestionListViewModel = new QuestionListViewModel
- {
- Questions = questionsQuery.Value.ToList()
- },
- RecentPopularTags = recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
- UserFavoriteTagListViewModel = new UserTagListViewModel
- {
- Header = "Favorite Tags",
- DivId1 = "interesting-tags",
- DivId2 = "interestingtags",
- Tags = lazyUserQuery == null
- ? null
- : (lazyUserQuery.Value.
- SingleOrDefault() ??
- new User()).FavoriteTags
- },
- UserIgnoredTagList = new UserTagListViewModel
- {
- Header = "Ignored Tags",
- DivId1 = "ignored-tags",
- DivId2 = "ignoredtags",
- Tags = null
- }
- };
+ {
+ Header = header,
+ QuestionListViewModel = new QuestionListViewModel
+ {
+ Questions = questionsQuery.Value.ToList()
+ },
+ RecentPopularTags = recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
+ UserFavoriteTagListViewModel = new UserTagListViewModel
+ {
+ Header = "Favorite Tags",
+ DivId1 = "interesting-tags",
+ DivId2 = "interestingtags",
+ Tags = lazyUserQuery == null
+ ? null
+ : (lazyUserQuery.Value.
+ SingleOrDefault() ??
+ new User()).FavoriteTags
+ },
+ UserIgnoredTagList = new UserTagListViewModel
+ {
+ Header = "Ignored Tags",
+ DivId1 = "ignored-tags",
+ DivId2 = "ignoredtags",
+ Tags = null
+ }
+ };
return View("Index", viewModel);
}
@@ -158,33 +159,33 @@ public ActionResult AggressiveIndex(string displayName, string tag)
Lazy<IEnumerable<User>> lazyUserQuery = (userQuery != null ? userQuery.Lazily() : null);
var viewModel = new IndexViewModel(ClaimsUser)
- {
- Header = header,
- QuestionListViewModel = new QuestionListViewModel
- {
- Questions = questionsQuery.Value.ToList()
- },
- RecentPopularTags =
- recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
- UserFavoriteTagListViewModel = new UserTagListViewModel
- {
- Header = "Favorite Tags",
- DivId1 = "interesting-tags",
- DivId2 = "interestingtags",
- Tags = lazyUserQuery == null
- ? null
- : (lazyUserQuery.Value.
- SingleOrDefault() ??
- new User()).FavoriteTags
- },
- UserIgnoredTagList = new UserTagListViewModel
- {
- Header = "Ignored Tags",
- DivId1 = "ignored-tags",
- DivId2 = "ignoredtags",
- Tags = null
- }
- };
+ {
+ Header = header,
+ QuestionListViewModel = new QuestionListViewModel
+ {
+ Questions = questionsQuery.Value.ToList()
+ },
+ RecentPopularTags =
+ recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
+ UserFavoriteTagListViewModel = new UserTagListViewModel
+ {
+ Header = "Favorite Tags",
+ DivId1 = "interesting-tags",
+ DivId2 = "interestingtags",
+ Tags = lazyUserQuery == null
+ ? null
+ : (lazyUserQuery.Value.
+ SingleOrDefault() ??
+ new User()).FavoriteTags
+ },
+ UserIgnoredTagList = new UserTagListViewModel
+ {
+ Header = "Ignored Tags",
+ DivId1 = "ignored-tags",
+ DivId2 = "ignoredtags",
+ Tags = null
+ }
+ };
return View("Index", viewModel);
}
@@ -194,25 +195,25 @@ public ActionResult Tag(string id)
{
RavenQueryStatistics stats;
List<Question> questions = DocumentSession.Query<Question>()
- .Statistics(out stats)
- .OrderByCreatedByDescending()
- .Take(20)
- .Where(x => x.Tags.Any(tag => tag == id))
- .ToList();
+ .Statistics(out stats)
+ .OrderByCreatedByDescending()
+ .Take(20)
+ .Where(x => x.Tags.Any(tag => tag == id))
+ .ToList();
return Json(new
- {
- Questions = questions,
- stats.TotalResults
- }, JsonRequestBehavior.AllowGet);
+ {
+ Questions = questions,
+ stats.TotalResults
+ }, JsonRequestBehavior.AllowGet);
}
public ActionResult Facets(string id)
{
var facets = DocumentSession.Query
<RecentPopularTagsMapOnly.ReduceResult, RecentPopularTagsMapOnly>()
- .Where(x => x.LastSeen > DateTime.UtcNow.AddMonths(-1).ToUtcToday())
- .ToFacets("Raven/Facets/Tags");
+ .Where(x => x.LastSeen > DateTime.UtcNow.AddMonths(-1).ToUtcToday())
+ .ToFacets("Raven/Facets/Tags");
return Json(facets, JsonRequestBehavior.AllowGet);
}
@@ -257,8 +258,8 @@ private IQueryable<QuestionWithDisplayName> QuestionQuery(string tag, out string
header = "Top Questions";
IQueryable<Question> questionsQuery = DocumentSession.Query<Question, Questions_Search>()
- .OrderByCreatedByDescending()
- .Take(20);
+ .OrderByCreatedByDescending()
+ .Take(20);
// Filter Questions by Tags?
if (!string.IsNullOrEmpty(tag))
@@ -275,9 +276,9 @@ private IQueryable<RecentPopularTags.ReduceResult> RecentPopularTagsQuery()
{
IQueryable<RecentPopularTags.ReduceResult> recentPopularTags =
DocumentSession.Query<RecentPopularTags.ReduceResult, RecentPopularTags>()
- .WithinTheLastMonth(1)
- .OrderByCountDescending()
- .Take(20);
+ .WithinTheLastMonth(1)
+ .OrderByCountDescending()
+ .Take(20);
return recentPopularTags;
}
View
25 Code/RavenOverflow.Web/RavenOverflow.Web.csproj
@@ -56,17 +56,17 @@
<Reference Include="CuttingEdge.Conditions, Version=1.2.0.11174, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\..\packages\CuttingEdge.Conditions.1.2.0.0\lib\NET35\CuttingEdge.Conditions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Abstractions, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Abstractions.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Abstractions.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.Lightweight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
+ <Reference Include="Raven.Client.Lightweight, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.2.0.2261\lib\net40\Raven.Client.Lightweight.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.2.0.2330\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
- <Reference Include="Raven.Client.MvcIntegration, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Raven.Client.MvcIntegration, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\packages\RavenDB.Client.MvcIntegration.2.0.2261\lib\net40\Raven.Client.MvcIntegration.dll</HintPath>
+ <HintPath>..\..\packages\RavenDB.Client.MvcIntegration.2.0.2330\lib\net40\Raven.Client.MvcIntegration.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>..\..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
@@ -95,14 +95,19 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\WebActivator.1.5\lib\net40\WebActivator.dll</HintPath>
</Reference>
+ <Reference Include="WorldDomination.Raven.Client">
+ <HintPath>..\..\packages\WorldDomination.Raven.Client.0.3.3\lib\net40\WorldDomination.Raven.Client.dll</HintPath>
+ </Reference>
<Reference Include="WorldDomination.Security">
<HintPath>..\..\packages\WorldDomination.Security.0.4.0\lib\net45\WorldDomination.Security.dll</HintPath>
</Reference>
- <Reference Include="WorldDomination.Web.Authentication">
- <HintPath>..\..\packages\WorldDomination.Web.Authentication.0.16.0\lib\net40\WorldDomination.Web.Authentication.dll</HintPath>
+ <Reference Include="WorldDomination.Web.Authentication, Version=0.19.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\packages\WorldDomination.Web.Authentication.0.19.0-Csrf-PewPew-4\lib\net40\WorldDomination.Web.Authentication.dll</HintPath>
</Reference>
- <Reference Include="WorldDomination.Web.Authentication.Mvc">
- <HintPath>..\..\packages\WorldDomination.Web.Authentication.Mvc.0.16.0\lib\net40\WorldDomination.Web.Authentication.Mvc.dll</HintPath>
+ <Reference Include="WorldDomination.Web.Authentication.Mvc, Version=0.19.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\packages\WorldDomination.Web.Authentication.Mvc.0.19.0-Csrf-PewPew-4\lib\net40\WorldDomination.Web.Authentication.Mvc.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
View
9 Code/RavenOverflow.Web/packages.config
@@ -4,13 +4,14 @@
<package id="CuttingEdge.Conditions" version="1.2.0.0" />
<package id="MagicalUnicornMvcErrorToolkit" version="1.0" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
- <package id="RavenDB.Client" version="2.0.2261" targetFramework="net40" />
- <package id="RavenDB.Client.MvcIntegration" version="2.0.2261" targetFramework="net40" />
+ <package id="RavenDB.Client" version="2.0.2330" targetFramework="net45" />
+ <package id="RavenDB.Client.MvcIntegration" version="2.0.2330" targetFramework="net45" />
<package id="RestSharp" version="104.1" targetFramework="net40" />
<package id="structuremap" version="2.6.4.1" targetFramework="net40" />
<package id="StructureMap.MVC3" version="1.0.8" />
<package id="WebActivator" version="1.5" />
+ <package id="WorldDomination.Raven.Client" version="0.3.3" targetFramework="net45" />
<package id="WorldDomination.Security" version="0.4.0" targetFramework="net45" />
- <package id="WorldDomination.Web.Authentication" version="0.16.0" targetFramework="net40" />
- <package id="WorldDomination.Web.Authentication.Mvc" version="0.16.0" targetFramework="net40" />
+ <package id="WorldDomination.Web.Authentication" version="0.19.0-Csrf-PewPew-4" targetFramework="net45" />
+ <package id="WorldDomination.Web.Authentication.Mvc" version="0.19.0-Csrf-PewPew-4" targetFramework="net45" />
</packages>

0 comments on commit b534abe

Please sign in to comment.
Something went wrong with that request. Please try again.