Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix Mono build errors

  • Loading branch information...
commit ade2505a58fe9544ed9336148d466f13f34f6b84 1 parent dfb43cf
@mythz mythz authored
Showing with 192 additions and 97 deletions.
  1. BIN  src/.DS_Store
  2. +1 −1  src/ServiceStack.FluentValidation.Mvc3/PropertyValidatorAdapters/FluentValidationPropertyValidator.cs
  3. +7 −8 src/ServiceStack.FluentValidation.Mvc3/ServiceStack.FluentValidation.Mvc3.csproj
  4. +2 −3 src/ServiceStack.Interfaces/ServiceStack.Interfaces.csproj
  5. +82 −6 src/ServiceStack.Razor/RazorFormat.cs
  6. +5 −3 src/ServiceStack.Razor/ServiceStack.Razor.csproj
  7. +1 −1  src/ServiceStack.Razor/ViewPage.cs
  8. +20 −3 src/ServiceStack.userprefs
  9. +1 −0  tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs
  10. +3 −3 tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs
  11. +3 −4 tests/ServiceStack.Common.Tests/OAuth/OrmLiteUserAuthTests.cs
  12. +1 −0  tests/ServiceStack.Common.Tests/Text/AdhocJsTests.cs
  13. +3 −4 tests/ServiceStack.Common.Tests/Xlinq/XlinqExtensionsTests.cs
  14. +1 −1  tests/ServiceStack.ServiceHost.Tests/ServiceCreationTests.cs
  15. +8 −11 tests/ServiceStack.ServiceHost.Tests/UseCase/Services/GetCustomerService.cs
  16. +5 −9 tests/ServiceStack.ServiceHost.Tests/UseCase/Services/StoreCustomersService.cs
  17. +1 −1  tests/ServiceStack.WebHost.IntegrationTests/Global.asax.cs
  18. +2 −1  tests/ServiceStack.WebHost.IntegrationTests/Services/IocServiceTests.cs
  19. +10 −10 tests/ServiceStack.WebHost.IntegrationTests/Services/MovieService.cs
  20. +2 −2 tests/ServiceStack.WebHost.IntegrationTests/Services/MoviesService.cs
  21. +3 −3 tests/ServiceStack.WebHost.IntegrationTests/Services/ResetMovies.cs
  22. +2 −2 tests/ServiceStack.WebHost.IntegrationTests/Services/UserAuths.cs
  23. +3 −0  tests/ServiceStack.WebHost.IntegrationTests/Tests/CustomerServiceValidationTests.cs
  24. +4 −1 tests/ServiceStack.WebHost.IntegrationTests/Tests/ExceptionHandlingTests.cs
  25. +2 −1  tests/ServiceStack.WebHost.IntegrationTests/Tests/ManageRolesTests.cs
  26. +16 −16 tests/ServiceStack.WebHost.IntegrationTests/Tests/MovieServiceTests.cs
  27. +3 −3 tests/ServiceStack.WebHost.IntegrationTests/Tests/RequestFilterTests.cs
  28. +1 −0  tests/ServiceStack.WebHost.IntegrationTests/Tests/WebServicesTests.cs
View
BIN  src/.DS_Store
Binary file not shown
View
2  ...tack.FluentValidation.Mvc3/PropertyValidatorAdapters/FluentValidationPropertyValidator.cs
@@ -65,7 +65,7 @@ public class FluentValidationPropertyValidator : ModelValidator {
public override IEnumerable<ModelClientValidationRule> GetClientValidationRules() {
if (!ShouldGenerateClientSideRules()) return Enumerable.Empty<ModelClientValidationRule>();
- var supportsClientValidation = Validator as IClientValidatable;
+ var supportsClientValidation = Validator as System.Web.Mvc.IClientValidatable;
if(supportsClientValidation != null) {
return supportsClientValidation.GetClientValidationRules(Metadata, ControllerContext);
View
15 src/ServiceStack.FluentValidation.Mvc3/ServiceStack.FluentValidation.Mvc3.csproj
@@ -10,7 +10,6 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ServiceStack.FluentValidation.Mvc3</RootNamespace>
<AssemblyName>ServiceStack.FluentValidation.Mvc3</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -31,20 +30,20 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="ServiceStack.Text, Version=3.2.2.5660, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
- <Reference Include="System.Web" />
- <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Mvc">
+ <HintPath>..\..\lib\System.Web.Mvc.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomizeValidatorAttribute.cs" />
View
5 src/ServiceStack.Interfaces/ServiceStack.Interfaces.csproj
@@ -68,6 +68,7 @@
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -475,9 +476,6 @@
<Compile Include="ServiceHost\IAsyncService.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="ServiceHost\ICanResolve.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="ServiceHost\IContentTypeFilter.cs">
<SubType>Code</SubType>
</Compile>
@@ -626,6 +624,7 @@
<Compile Include="Translators\TranslateMemberAttribute.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="ServiceHost\IResolver.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
View
88 src/ServiceStack.Razor/RazorFormat.cs
@@ -86,6 +86,73 @@ public RazorFormat()
RegisterNamespacesInConfig();
}
+ //From XlinqExtensions to avoid Mono build error
+ public static XElement AnyElement(XElement element, string name)
+ {
+ if (element == null) return null;
+ foreach (var node in element.Nodes())
+ {
+ if (node.NodeType != System.Xml.XmlNodeType.Element) continue;
+ var childEl = (XElement)node;
+ if (childEl.Name.LocalName == name)
+ {
+ return childEl;
+ }
+ }
+ return null;
+ }
+
+ public static XElement AnyElement(IEnumerable<XElement> elements, string name)
+ {
+ foreach (var element in elements)
+ {
+ if (element.Name.LocalName == name)
+ {
+ return element;
+ }
+ }
+ return null;
+ }
+
+ public static IEnumerable<XElement> AllElements(IEnumerable<XElement> elements, string name)
+ {
+ var els = new List<XElement>();
+ foreach (var element in elements)
+ {
+ els.AddRange(AllElements(element, name));
+ }
+ return els;
+ }
+
+ public static IEnumerable<XElement> AllElements(XElement element, string name)
+ {
+ var els = new List<XElement>();
+ if (element == null) return els;
+ foreach (var node in element.Nodes())
+ {
+ if (node.NodeType != System.Xml.XmlNodeType.Element) continue;
+ var childEl = (XElement)node;
+ if (childEl.Name.LocalName == name)
+ {
+ els.Add(childEl);
+ }
+ }
+ return els;
+ }
+
+ public static XAttribute AnyAttribute(XElement element, string name)
+ {
+ if (element == null) return null;
+ foreach (var attribute in element.Attributes())
+ {
+ if (attribute.Name.LocalName == name)
+ {
+ return attribute;
+ }
+ }
+ return null;
+ }
+
private void RegisterNamespacesInConfig()
{
//Infer from <system.web.webPages.razor> - what VS.NET's intell-sense uses
@@ -94,12 +161,21 @@ private void RegisterNamespacesInConfig()
{
var xml = configPath.ReadAllText();
var doc = XElement.Parse(xml);
- doc.AnyElement("system.web.webPages.razor")
- .AnyElement("pages")
- .AnyElement("namespaces")
- .AllElements("add").ToList()
- .ForEach(x => TemplateNamespaces.Add(x.AnyAttribute("namespace").Value));
- }
+// doc.AnyElement("system.web.webPages.razor")
+// .AnyElement("pages")
+// .AnyElement("namespaces")
+// .AllElements("add").ToList()
+// .ForEach(x => TemplateNamespaces.Add(x.AnyAttribute("namespace").Value));
+
+ //re-written to avoid Mono build error
+ var els = AllElements(
+ AnyElement(AnyElement(AnyElement(
+ doc, "system.web.webPages.razor"),
+ "pages"),
+ "namespaces"),
+ "add").ToList();
+ els.ForEach(x => TemplateNamespaces.Add(AnyAttribute(x, "namespace").Value));
+ }
//E.g. <add key="servicestack.razor.namespaces" value="System,ServiceStack.Text" />
if (ConfigUtils.GetNullableAppSetting(NamespacesAppSettingsKey) != null)
View
8 src/ServiceStack.Razor/ServiceStack.Razor.csproj
@@ -55,6 +55,7 @@
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ServiceStack.Text">
@@ -63,9 +64,7 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
- <Reference Include="System.Web">
- <HintPath>C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll</HintPath>
- </Reference>
+ <Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -74,6 +73,9 @@
<Reference Include="System.Web.Razor">
<HintPath>..\..\lib\System.Web.Razor.dll</HintPath>
</Reference>
+ <Reference Include="System.Web.Mvc">
+ <HintPath>..\..\lib\System.Web.Mvc.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Compilation\CompilerServiceBase.cs" />
View
2  src/ServiceStack.Razor/ViewPage.cs
@@ -179,7 +179,7 @@ private static string HtmlEncode(object value)
return null;
}
- var str = value as IHtmlString;
+ var str = value as System.Web.IHtmlString;
return str != null ? str.ToHtmlString() : HttpUtility.HtmlEncode(Convert.ToString(value, CultureInfo.CurrentCulture));
}
View
23 src/ServiceStack.userprefs
@@ -1,9 +1,26 @@
<Properties>
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
- <MonoDevelop.Ide.Workbench>
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
+ <MonoDevelop.Ide.Workbench ActiveDocument="ServiceStack.FluentValidation.Mvc3/FluentValidationModelMetadataProvider.cs">
+ <Files>
+ <File FileName="../tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs" Line="208" Column="55" />
+ <File FileName="../tests/ServiceStack.Common.Tests/Text/AdhocJsTests.cs" Line="66" Column="39" />
+ <File FileName="../tests/ServiceStack.ServiceHost.Tests/ServiceCreationTests.cs" Line="73" Column="4" />
+ <File FileName="../tests/ServiceStack.WebHost.Endpoints.Tests/AppHostListenerBaseTests.cs" Line="7" Column="24" />
+ <File FileName="../tests/ServiceStack.WebHost.Endpoints.Tests/AuthTests.cs" Line="157" Column="7" />
+ <File FileName="../tests/ServiceStack.WebHost.Endpoints.Tests/CustomerServiceValidationTests.cs" Line="325" Column="54" />
+ <File FileName="../tests/ServiceStack.WebHost.Endpoints.Tests/RemoteEndDropsConnectionTests.cs" Line="5" Column="24" />
+ <File FileName="../tests/ServiceStack.WebHost.Endpoints.Tests/UserServiceValidationTests.cs" Line="13" Column="24" />
+ <File FileName="ServiceStack.FluentValidation.Mvc3/CustomizeValidatorAttribute.cs" Line="21" Column="33" />
+ <File FileName="ServiceStack.FluentValidation.Mvc3/Mvc/MiniProfiler/MiniProfiler.cs" Line="61" Column="7" />
+ <File FileName="ServiceStack/MiniProfiler/UI/MiniProfilerHandler.cs" Line="32" Column="27" />
+ <File FileName="ServiceStack.FluentValidation.Mvc3/FluentValidationModelMetadataProvider.cs" Line="61" Column="53" />
+ </Files>
<Pads>
<Pad Id="ProjectPad">
- <State expanded="True" selected="True" />
+ <State expanded="True">
+ <Node name="Tests" expanded="True" />
+ <Node name="ServiceStack.FluentValidation.Mvc3" selected="True" />
+ </State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
View
1  tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionTests.cs
@@ -208,6 +208,7 @@ public void Logging_in_pulls_all_AuthInfo_from_repo_after_logging_in_all_AuthPro
Password = registrationDto.Password,
});
+ loginResponse.PrintDump();
oAuthUserSession = requestContext.ReloadSession();
Assert.That(oAuthUserSession.TwitterUserId, Is.EqualTo(authInfo["user_id"]));
View
6 tests/ServiceStack.Common.Tests/OAuth/OAuthUserSessionWithoutTestSourceTests.cs
@@ -45,9 +45,9 @@ public void SetUp()
else
{
var sqliteInMemoryRepo = new OrmLiteAuthRepository(dbFactory);
- dbFactory.Exec(dbCmd => {
- dbCmd.CreateTable<UserAuth>(true);
- dbCmd.CreateTable<UserOAuthProvider>(true);
+ dbFactory.Run(db => {
+ db.CreateTable<UserAuth>(true);
+ db.CreateTable<UserOAuthProvider>(true);
});
sqliteInMemoryRepo.Clear();
userAuthRepositorys.Add(sqliteInMemoryRepo);
View
7 tests/ServiceStack.Common.Tests/OAuth/OrmLiteUserAuthTests.cs
@@ -21,9 +21,8 @@ public void Can_insert_table_with_UserAuth()
File.Delete(connectionString);
using (var db = connectionString.OpenDbConnection())
- using (var dbCmd = db.CreateCommand())
{
- dbCmd.CreateTable<UserAuth>(true);
+ db.CreateTable<UserAuth>(true);
//var userAuth = new UserAuth {
// Id = 1,
@@ -42,9 +41,9 @@ public void Can_insert_table_with_UserAuth()
var jsv = "{Id:0,UserName:UserName,Email:as@if.com,PrimaryEmail:as@if.com,FirstName:FirstName,LastName:LastName,DisplayName:DisplayName,Salt:WMQi/g==,PasswordHash:oGdE40yKOprIgbXQzEMSYZe3vRCRlKGuqX2i045vx50=,Roles:[],Permissions:[],CreatedDate:2012-03-20T07:53:48.8720739Z,ModifiedDate:2012-03-20T07:53:48.8720739Z}";
var userAuth = jsv.To<UserAuth>();
- dbCmd.Insert(userAuth);
+ db.Insert(userAuth);
- var rows = dbCmd.Select<UserAuth>(q => q.UserName == "UserName");
+ var rows = db.Select<UserAuth>(q => q.UserName == "UserName");
Console.WriteLine(rows[0].Dump());
View
1  tests/ServiceStack.Common.Tests/Text/AdhocJsTests.cs
@@ -71,6 +71,7 @@ public void Deserialize_array_with_null_elements()
{
var json = "[{\"Value\": \"a\"},null,{\"Value\": \"b\"}]";
var o = JsonSerializer.DeserializeFromString<A[]>(json);
+ o.PrintDump();
}
}
}
View
7 tests/ServiceStack.Common.Tests/Xlinq/XlinqExtensionsTests.cs
@@ -53,9 +53,8 @@ public void Insert_data_from_xml_into_db()
var element2 = XElement.Parse(xml).AnyElement("Body").AnyElement("Element1").AnyElement("Element2");
using (var db = ":memory:".OpenDbConnection())
- using (var dbCmd = db.CreateCommand())
{
- dbCmd.CreateTable<XmlData>(true);
+ db.CreateTable<XmlData>(true);
foreach (var element3 in element2.AllElements("Element3"))
{
var xmlData = new XmlData {
@@ -65,9 +64,9 @@ public void Insert_data_from_xml_into_db()
Amount = int.Parse(element3.FirstElement().FirstElement().AnyAttribute("amount").Value),
Price = decimal.Parse(element3.FirstElement().FirstElement().AnyAttribute("price").Value),
};
- dbCmd.Insert(xmlData);
+ db.Insert(xmlData);
}
- dbCmd.Select<XmlData>().ForEach(x => Console.WriteLine(TypeSerializer.SerializeToString(x)));
+ db.Select<XmlData>().ForEach(x => Console.WriteLine(TypeSerializer.SerializeToString(x)));
}
}
View
2  tests/ServiceStack.ServiceHost.Tests/ServiceCreationTests.cs
@@ -78,7 +78,7 @@ public void OnTestFixtureTearDown()
appHost.Dispose();
}
- static IRestClient[] RestClients =
+ protected static IRestClient[] RestClients =
{
new JsonServiceClient(ServiceClientBaseUri),
new XmlServiceClient(ServiceClientBaseUri),
View
19 tests/ServiceStack.ServiceHost.Tests/UseCase/Services/GetCustomerService.cs
@@ -13,12 +13,12 @@ public class GetCustomerService
{
private static readonly string CacheKey = typeof (GetCustomer).Name;
- private readonly IDbConnection dbConn;
+ private readonly IDbConnection db;
private readonly CustomerUseCaseConfig config;
public GetCustomerService(IDbConnection dbConn, CustomerUseCaseConfig config)
{
- this.dbConn = dbConn;
+ this.db = dbConn;
this.config = config;
}
@@ -32,17 +32,14 @@ public object Execute(GetCustomer request)
if (inCache != null) return inCache;
}
- using (var dbCmd = dbConn.CreateCommand())
- {
- var response = new GetCustomerResponse {
- Customer = dbCmd.GetById<Customer>(request.CustomerId)
- };
+ var response = new GetCustomerResponse {
+ Customer = db.GetById<Customer>(request.CustomerId)
+ };
- if (config.UseCache)
- this.CacheClient.Set(CacheKey, response);
+ if (config.UseCache)
+ this.CacheClient.Set(CacheKey, response);
- return response;
- }
+ return response;
}
}
}
View
14 tests/ServiceStack.ServiceHost.Tests/UseCase/Services/StoreCustomersService.cs
@@ -8,24 +8,20 @@ namespace ServiceStack.ServiceHost.Tests.UseCase.Services
public class StoreCustomersService
: IService<StoreCustomers>
{
- private readonly IDbConnection dbConn;
+ private readonly IDbConnection db;
public StoreCustomersService(IDbConnection dbConn)
{
- this.dbConn = dbConn;
+ this.db = dbConn;
//Console.WriteLine("StoreCustomersService()");
}
public object Execute(StoreCustomers request)
{
- using (var dbCmd = dbConn.CreateCommand())
+ db.CreateTable<Customer>(false);
+ foreach (var customer in request.Customers)
{
- dbCmd.CreateTable<Customer>(false);
-
- foreach (var customer in request.Customers)
- {
- dbCmd.Insert(customer);
- }
+ db.Insert(customer);
}
return null;
View
2  tests/ServiceStack.WebHost.IntegrationTests/Global.asax.cs
@@ -72,7 +72,7 @@ public override void Configure(Container container)
// c => new SessionFactory(c.Resolve<ICacheClient>()));
var dbFactory = this.Container.Resolve<IDbConnectionFactory>();
- dbFactory.Exec(dbCmd => dbCmd.CreateTable<Movie>(true));
+ dbFactory.Run(db => db.CreateTable<Movie>(true));
ModelConfig<Movie>.Id(x => x.Title);
Routes
.Add<Movies>("/custom-movies", "GET, OPTIONS")
View
3  tests/ServiceStack.WebHost.IntegrationTests/Services/IocServiceTests.cs
@@ -99,7 +99,8 @@ public void Does_create_correct_instances_per_scope()
var response1 = restClient.Get<IocScopeResponse>("iocscope");
var response2 = restClient.Get<IocScopeResponse>("iocscope");
- Console.WriteLine(response2.Dump());
+ response1.PrintDump();
+ response2.PrintDump();
Assert.That(response2.Results[typeof(FunqSingletonScope).Name], Is.EqualTo(1));
Assert.That(response2.Results[typeof(FunqRequestScope).Name], Is.EqualTo(2));
View
20 tests/ServiceStack.WebHost.IntegrationTests/Services/MovieService.cs
@@ -95,7 +95,7 @@ public class MovieService : RestServiceBase<Movie>
public override object OnGet(Movie movie)
{
return new MovieResponse {
- Movie = DbFactory.Exec(dbCmd => dbCmd.GetById<Movie>(movie.Id))
+ Movie = DbFactory.Run(db => db.GetById<Movie>(movie.Id))
};
}
@@ -104,13 +104,13 @@ public override object OnGet(Movie movie)
/// </summary>
public override object OnPost(Movie movie)
{
- var newMovieId = DbFactory.Exec(dbCmd => {
- dbCmd.Insert(movie);
- return dbCmd.GetLastInsertId();
+ var newMovieId = DbFactory.Run(db => {
+ db.Insert(movie);
+ return db.GetLastInsertId();
});
var newMovie = new MovieResponse {
- Movie = DbFactory.Exec(dbCmd => dbCmd.GetById<Movie>(newMovieId))
+ Movie = DbFactory.Run(db => db.GetById<Movie>(newMovieId))
};
return new HttpResult(newMovie) {
StatusCode = HttpStatusCode.Created,
@@ -125,7 +125,7 @@ public override object OnPost(Movie movie)
/// </summary>
public override object OnPut(Movie movie)
{
- DbFactory.Exec(dbCmd => dbCmd.Update(movie));
+ DbFactory.Run(db => db.Update(movie));
return new MovieResponse();
}
@@ -134,7 +134,7 @@ public override object OnPut(Movie movie)
/// </summary>
public override object OnDelete(Movie request)
{
- DbFactory.Exec(dbCmd => dbCmd.DeleteById<Movie>(request.Id));
+ DbFactory.Run(db => db.DeleteById<Movie>(request.Id));
return new MovieResponse();
}
@@ -143,11 +143,11 @@ public override object OnDelete(Movie request)
/// </summary>
public override object OnPatch(Movie movie)
{
- DbFactory.Exec(dbCmd => {
- var existingMovie = dbCmd.GetById<Movie>(movie.Id);
+ DbFactory.Run(db => {
+ var existingMovie = db.GetById<Movie>(movie.Id);
if (movie.Title != null)
existingMovie.Title = movie.Title;
- dbCmd.Save(existingMovie);
+ db.Save(existingMovie);
});
return new MovieResponse();
}
View
4 tests/ServiceStack.WebHost.IntegrationTests/Services/MoviesService.cs
@@ -40,8 +40,8 @@ public override object OnGet(Movies request)
return new MoviesResponse
{
Movies = request.Genre.IsNullOrEmpty()
- ? DbFactory.Exec(dbCmd => dbCmd.Select<Movie>())
- : DbFactory.Exec(dbCmd => dbCmd.Select<Movie>("Genres LIKE {0}", "%" + request.Genre + "%"))
+ ? DbFactory.Run(db => db.Select<Movie>())
+ : DbFactory.Run(db => db.Select<Movie>("Genres LIKE {0}", "%" + request.Genre + "%"))
};
}
}
View
6 tests/ServiceStack.WebHost.IntegrationTests/Services/ResetMovies.cs
@@ -43,11 +43,11 @@ public class ResetMoviesService : RestServiceBase<ResetMovies>
public override object OnPost(ResetMovies request)
{
- DbFactory.Exec(dbCmd =>
+ DbFactory.Run(db =>
{
const bool overwriteTable = true;
- dbCmd.CreateTable<Movie>(overwriteTable);
- dbCmd.SaveAll(Top5Movies);
+ db.CreateTable<Movie>(overwriteTable);
+ db.SaveAll(Top5Movies);
});
return new ResetMoviesResponse();
View
4 tests/ServiceStack.WebHost.IntegrationTests/Services/UserAuths.cs
@@ -36,8 +36,8 @@ public class UserAuthsService : ServiceBase<UserAuths>
protected override object Run(UserAuths request)
{
return new UserAuthsResponse {
- Results = DbFactory.Exec(dbCmd => dbCmd.Select<UserAuth>()),
- OAuthProviders = DbFactory.Exec(dbCmd => dbCmd.Select<UserOAuthProvider>()),
+ Results = DbFactory.Run(db => db.Select<UserAuth>()),
+ OAuthProviders = DbFactory.Run(db => db.Select<UserOAuthProvider>()),
};
}
}
View
3  tests/ServiceStack.WebHost.IntegrationTests/Tests/CustomerServiceValidationTests.cs
@@ -3,6 +3,7 @@
using System.Net;
using NUnit.Framework;
using ServiceStack.Service;
+using ServiceStack.Text;
using ServiceStack.ServiceClient.Web;
using ServiceStack.WebHost.IntegrationTests.Services;
@@ -67,6 +68,7 @@ public void Post_empty_request_throws_validation_exception(IServiceClient client
try
{
var response = client.Send<CustomersResponse>(new Customers());
+ response.PrintDump();
Assert.Fail("Should throw Validation Exception");
}
catch (WebServiceException ex)
@@ -90,6 +92,7 @@ public void Get_empty_request_throws_validation_exception(IRestClient client)
try
{
var response = client.Get<CustomersResponse>("/Customers");
+ response.PrintDump();
Assert.Fail("Should throw Validation Exception");
}
catch (WebServiceException ex)
View
5 tests/ServiceStack.WebHost.IntegrationTests/Tests/ExceptionHandlingTests.cs
@@ -84,7 +84,7 @@ public class ExceptionHandlingTests
{
private const string ListeningOn = Config.ServiceStackBaseUri + "/";
- static IRestClient[] ServiceClients =
+ protected static IRestClient[] ServiceClients =
{
new JsonServiceClient(ListeningOn),
new XmlServiceClient(ListeningOn),
@@ -172,6 +172,7 @@ public void Returns_populated_dto_when_has_ResponseStatus()
try
{
var json = PredefinedJsonUrl<ExceptionWithResponseStatus>().GetJsonFromUrl();
+ json.PrintDump();
Assert.Fail("Should throw");
}
catch (WebException webEx)
@@ -189,6 +190,7 @@ public void Returns_empty_dto_when_NoResponseStatus()
try
{
var json = PredefinedJsonUrl<ExceptionNoResponseStatus>().GetJsonFromUrl();
+ json.PrintDump();
Assert.Fail("Should throw");
}
catch (WebException webEx)
@@ -205,6 +207,7 @@ public void Returns_no_body_when_NoResponseDto()
try
{
var json = PredefinedJsonUrl<ExceptionNoResponseDto>().GetJsonFromUrl();
+ json.PrintDump();
Assert.Fail("Should throw");
}
catch (WebException webEx)
View
3  tests/ServiceStack.WebHost.IntegrationTests/Tests/ManageRolesTests.cs
@@ -12,7 +12,7 @@ namespace ServiceStack.WebHost.IntegrationTests.Tests
[TestFixture]
public class ManageRolesTests : AuthTestsBase
{
- private Registration registration;
+ protected Registration registration;
[TestFixtureSetUp]
public void TestFixtureSetUp()
@@ -62,6 +62,7 @@ public void Cannot_assign_roles_with_normal_user()
Permissions = { Permission1, Permission2 }
});
+ response.PrintDump();
Assert.Fail("Should not be allowed");
}
catch (WebServiceException webEx)
View
32 tests/ServiceStack.WebHost.IntegrationTests/Tests/MovieServiceTests.cs
@@ -40,7 +40,7 @@ public override void OnBeforeEachTest()
SqliteOrmLiteDialectProvider.Instance));
this.DbFactory = this.Container.Resolve<IDbConnectionFactory>();
- this.DbFactory.Exec(dbCmd => dbCmd.CreateTable<Movie>(true));
+ this.DbFactory.Run(db => db.CreateTable<Movie>(true));
}
[Test]
@@ -48,13 +48,13 @@ public void Can_PATCH_Movie_from_dto()
{
ExecutePath(HttpMethods.Post, "/movies", null, null, NewMovie);
- var lastInsertId = (int)this.DbFactory.Exec(dbCmd => dbCmd.GetLastInsertId());
+ var lastInsertId = (int)this.DbFactory.Run(db => db.GetLastInsertId());
var patchMovie = new Movie { Id = lastInsertId, Title = "PATCHED " + NewMovie.Title };
ExecutePath(HttpMethods.Patch, "/movies", null, null, patchMovie);
- this.DbFactory.Exec(dbCmd => {
- var movie = dbCmd.GetById<Movie>(lastInsertId);
+ this.DbFactory.Run(db => {
+ var movie = db.GetById<Movie>(lastInsertId);
Assert.That(movie, Is.Not.Null);
Assert.That(movie.Title, Is.EqualTo(patchMovie.Title));
});
@@ -66,10 +66,10 @@ public void Can_create_new_Movie_from_FormData()
var formData = NewMovie.ToStringDictionary();
var response = ExecutePath(HttpMethods.Post, "/movies", null, formData, null);
-
- this.DbFactory.Exec(dbCmd => {
- var lastInsertId = dbCmd.GetLastInsertId();
- var createdMovie = dbCmd.GetById<Movie>(lastInsertId);
+ response.PrintDump();
+ this.DbFactory.Run(db => {
+ var lastInsertId = db.GetLastInsertId();
+ var createdMovie = db.GetById<Movie>(lastInsertId);
Assert.That(createdMovie, Is.Not.Null);
Assert.That(createdMovie, Is.EqualTo(NewMovie));
});
@@ -79,10 +79,10 @@ public void Can_create_new_Movie_from_FormData()
public void Can_create_new_Movie_from_dto()
{
var response = ExecutePath(HttpMethods.Post, "/movies", null, null, NewMovie);
-
- this.DbFactory.Exec(dbCmd => {
- var lastInsertId = dbCmd.GetLastInsertId();
- var createdMovie = dbCmd.GetById<Movie>(lastInsertId);
+ response.PrintDump();
+ this.DbFactory.Run(db => {
+ var lastInsertId = db.GetLastInsertId();
+ var createdMovie = db.GetById<Movie>(lastInsertId);
Assert.That(createdMovie, Is.Not.Null);
Assert.That(createdMovie, Is.EqualTo(NewMovie));
});
@@ -92,9 +92,9 @@ public void Can_create_new_Movie_from_dto()
public void Can_POST_to_resetmovies()
{
var response = ExecutePath(HttpMethods.Post, "/reset-movies");
-
- this.DbFactory.Exec(dbCmd => {
- var movies = dbCmd.Select<Movie>();
+ response.PrintDump();
+ this.DbFactory.Run(db => {
+ var movies = db.Select<Movie>();
Assert.That(movies.Count, Is.EqualTo(ResetMoviesService.Top5Movies.Count));
});
}
@@ -105,7 +105,7 @@ public void Error_calling_GET_on_resetmovies()
try
{
var response = (ResetMoviesResponse)ExecutePath(HttpMethods.Get, "/reset-movies");
- Console.WriteLine(response.Dump());
+ response.PrintDump();
Assert.Fail("Should throw HTTP errors");
}
catch (WebServiceException webEx)
View
6 tests/ServiceStack.WebHost.IntegrationTests/Tests/RequestFilterTests.cs
@@ -19,7 +19,7 @@ public void Does_return_bare_401_StatusCode()
+ "/json/syncreply/RequestFilter?StatusCode=401");
var webResponse = (HttpWebResponse)webRequest.GetResponse();
-
+ webResponse.Method.Print();
Assert.Fail("Should throw 401 WebException");
}
catch (WebException ex)
@@ -40,7 +40,7 @@ public void Does_return_bare_401_with_AuthRequired_header()
+ "&HeaderValue=" + "Basic realm=\"Auth Required\"".UrlEncode());
var webResponse = (HttpWebResponse)webRequest.GetResponse();
-
+ webResponse.Method.Print();
Assert.Fail("Should throw 401 WebException");
}
catch (WebException ex)
@@ -63,7 +63,7 @@ public void Does_return_send_401_for_access_to_ISecure_requests()
+ "/json/syncreply/Secure?SessionId=175BEA29-DC79-4555-BD42-C4DD5D57A004");
var webResponse = (HttpWebResponse)webRequest.GetResponse();
-
+ webResponse.Method.Print();
Assert.Fail("Should throw 401 WebException");
}
catch (WebException ex)
View
1  tests/ServiceStack.WebHost.IntegrationTests/Tests/WebServicesTests.cs
@@ -58,6 +58,7 @@ public void Can_Handle_Exception_from_AlwaysThrowService()
var response = client.Send<AlwaysThrowsResponse>(
new AlwaysThrows { Value = TestString });
+ response.PrintDump();
Assert.Fail("Should throw HTTP errors");
}
catch (WebServiceException webEx)
Please sign in to comment.
Something went wrong with that request. Please try again.