Browse Source

Some more tests and namespaces fixed

pull/65/head
Sebastian Stehle 9 years ago
parent
commit
b068590bb6
  1. 2
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/MongoContentRepository.cs
  2. 2
      src/Squidex.Domain.Apps.Read/Contents/Edm/EdmModelBuilder.cs
  3. 2
      src/Squidex.Domain.Apps.Read/Contents/JsonSchema/ContentSchemaBuilder.cs
  4. 10
      src/Squidex.Infrastructure/StringExtensions.cs
  5. 2
      src/Squidex/Config/Domain/ReadModule.cs
  6. 2
      src/Squidex/Controllers/ContentApi/Generator/SchemaSwaggerGenerator.cs
  7. 2
      tests/Squidex.Domain.Apps.Read.Tests/MongoDb/Contents/ODataQueryTests.cs
  8. 6
      tests/Squidex.Infrastructure.Tests/Assets/FolderAssetStoreTests.cs
  9. 31
      tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs

2
src/Squidex.Domain.Apps.Read.MongoDb/Contents/MongoContentRepository.cs

@ -15,7 +15,7 @@ using MongoDB.Bson;
using MongoDB.Driver;
using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Contents;
using Squidex.Domain.Apps.Read.Contents.Builders;
using Squidex.Domain.Apps.Read.Contents.Edm;
using Squidex.Domain.Apps.Read.Contents.Repositories;
using Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors;
using Squidex.Domain.Apps.Read.Schemas;

2
src/Squidex.Domain.Apps.Read/Contents/Builders/EdmModelBuilder.cs → src/Squidex.Domain.Apps.Read/Contents/Edm/EdmModelBuilder.cs

@ -16,7 +16,7 @@ using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Domain.Apps.Read.Utils;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Read.Contents.Builders
namespace Squidex.Domain.Apps.Read.Contents.Edm
{
public sealed class EdmModelBuilder : CachingProviderBase
{

2
src/Squidex.Domain.Apps.Read/Contents/Builders/ContentSchemaBuilder.cs → src/Squidex.Domain.Apps.Read/Contents/JsonSchema/ContentSchemaBuilder.cs

@ -10,7 +10,7 @@ using NJsonSchema;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Read.Contents.Builders
namespace Squidex.Domain.Apps.Read.Contents.JsonSchema
{
public sealed class ContentSchemaBuilder
{

10
src/Squidex.Infrastructure/StringExtensions.cs

@ -27,9 +27,9 @@ namespace Squidex.Infrastructure
return value != null && PropertyNameRegex.IsMatch(value);
}
public static string ToCamelCase(this string value)
public static string WithFallback(this string value, string fallback)
{
return char.ToLower(value[0]) + value.Substring(1);
return !string.IsNullOrWhiteSpace(value) ? value.Trim() : fallback;
}
public static string ToPascalCase(this string value)
@ -37,9 +37,11 @@ namespace Squidex.Infrastructure
return string.Concat(value.Split(new[] { '-', '_', ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(c => char.ToUpper(c[0]) + c.Substring(1)));
}
public static string WithFallback(this string value, string fallback)
public static string ToCamelCase(this string value)
{
return !string.IsNullOrWhiteSpace(value) ? value.Trim() : fallback;
value = value.ToPascalCase();
return char.ToLower(value[0]) + value.Substring(1);
}
}
}

2
src/Squidex/Config/Domain/ReadModule.cs

@ -15,7 +15,7 @@ using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Apps.Services;
using Squidex.Domain.Apps.Read.Apps.Services.Implementations;
using Squidex.Domain.Apps.Read.Contents;
using Squidex.Domain.Apps.Read.Contents.Builders;
using Squidex.Domain.Apps.Read.Contents.Edm;
using Squidex.Domain.Apps.Read.History;
using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Domain.Apps.Read.Schemas.Services;

2
src/Squidex/Controllers/ContentApi/Generator/SchemaSwaggerGenerator.cs

@ -13,7 +13,7 @@ using NJsonSchema;
using NSwag;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Read.Contents.Builders;
using Squidex.Domain.Apps.Read.Contents.JsonSchema;
using Squidex.Infrastructure;
using Squidex.Pipeline.Swagger;

2
tests/Squidex.Domain.Apps.Read.Tests/MongoDb/Contents/ODataQueryTests.cs

@ -17,7 +17,7 @@ using Moq;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Read.Apps;
using Squidex.Domain.Apps.Read.Contents.Builders;
using Squidex.Domain.Apps.Read.Contents.Edm;
using Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors;
using Squidex.Domain.Apps.Read.Schemas;
using Squidex.Infrastructure;

6
tests/Squidex.Infrastructure.Tests/Assets/FolderAssetStoreTests.cs

@ -41,6 +41,12 @@ namespace Squidex.Infrastructure.Assets
Assert.True(Directory.Exists(testFolder));
}
[Fact]
public void Should_throw_when_creating_directory_failed()
{
Assert.Throws<ConfigurationException>(() => new FolderAssetStore("Z:\\Foo", new Mock<ISemanticLog>().Object).Connect());
}
[Fact]
public Task Should_throw_exception_if_asset_not_found()
{

31
tests/Squidex.Infrastructure.Tests/StringExtensionsTests.cs

@ -18,12 +18,37 @@ namespace Squidex.Infrastructure
[InlineData("my property", "MyProperty")]
[InlineData("my_property", "MyProperty")]
[InlineData("my-property", "MyProperty")]
[InlineData("my property", "MyProperty")]
[InlineData("my__property", "MyProperty")]
[InlineData("my--property", "MyProperty")]
public void Should_convert_to_pascal_case(string input, string output)
{
Assert.Equal(output, input.ToPascalCase());
}
[Theory]
[InlineData("My", "my")]
[InlineData("MyProperty ", "myProperty")]
[InlineData("My property", "myProperty")]
[InlineData("My_property", "myProperty")]
[InlineData("My-property", "myProperty")]
public void Should_convert_to_camel_case(string input, string output)
{
Assert.Equal(output, input.ToCamelCase());
}
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void Should_provide_fallback_if_invalid(string value)
{
Assert.Equal("fallback", value.WithFallback("fallback"));
}
[Fact]
public void Should_provide_value()
{
const string value = "value";
Assert.Equal(value, value.WithFallback("fallback"));
}
}
}

Loading…
Cancel
Save