-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/1708 sql incremental naming (#1713)
* Add missing tracer to MsSql integration test platform. * Move 2 tests to integration tests. * Fix: throw correct exception. * Fix ServicesTests
- Loading branch information
Showing
7 changed files
with
121 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Tests/SenseNet.IntegrationTests/InMemTests/InMemIncrementalNamingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SenseNet.IntegrationTests.Infrastructure; | ||
using SenseNet.IntegrationTests.Platforms; | ||
using SenseNet.IntegrationTests.TestCases; | ||
|
||
namespace SenseNet.IntegrationTests.InMemTests | ||
{ | ||
[TestClass] | ||
public class InMemIncrementalNamingTests : IntegrationTest<InMemPlatform, IncrementalNamingTestCases> | ||
{ | ||
[TestMethod] | ||
public void IntT_InMem_ContentNaming_AllowIncrementalNaming_Allowed() { TestCase.ContentNaming_AllowIncrementalNaming_Allowed(); } | ||
[TestMethod] | ||
public void IntT_InMem_ContentNaming_AllowIncrementalNaming_Disallowed() { TestCase.ContentNaming_AllowIncrementalNaming_Disallowed(); } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Tests/SenseNet.IntegrationTests/MsSqlTests/MsSqlIncrementalNamingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SenseNet.IntegrationTests.Infrastructure; | ||
using SenseNet.IntegrationTests.Platforms; | ||
using SenseNet.IntegrationTests.TestCases; | ||
|
||
namespace SenseNet.IntegrationTests.MsSqlTests | ||
{ | ||
[TestClass] | ||
public class MsSqlIncrementalNamingTests : IntegrationTest<MsSqlPlatform, IncrementalNamingTestCases> | ||
{ | ||
[TestMethod] | ||
public void IntT_MsSql_ContentNaming_AllowIncrementalNaming_Allowed() { TestCase.ContentNaming_AllowIncrementalNaming_Allowed(); } | ||
[TestMethod] | ||
public void IntT_MsSql_ContentNaming_AllowIncrementalNaming_Disallowed() { TestCase.ContentNaming_AllowIncrementalNaming_Disallowed(); } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/Tests/SenseNet.IntegrationTests/TestCases/IncrementalNamingTestCases.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SenseNet.ContentRepository; | ||
using SenseNet.ContentRepository.Schema; | ||
using SenseNet.ContentRepository.Storage.Data; | ||
using SenseNet.IntegrationTests.Infrastructure; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace SenseNet.IntegrationTests.TestCases | ||
{ | ||
public class IncrementalNamingTestCases : TestCaseBase | ||
{ | ||
private static string ContentType_IncrementalNamingAllowedName = "ContentType_IncrementalNamingAllowed"; | ||
private static string ContentType_IncrementalNamingDisallowedName = "ContentType_IncrementalNamingDisallowed"; | ||
private static ContentType ContentType_IncrementalNamingAllowed; | ||
private static ContentType ContentType_IncrementalNamingDisallowed; | ||
public static void InstallContentTypes() | ||
{ | ||
var ctdformat = @"<?xml version=""1.0"" encoding=""utf-8""?> | ||
<ContentType name=""{0}"" parentType=""Car"" handler=""SenseNet.ContentRepository.GenericContent"" | ||
xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition""> | ||
<AllowIncrementalNaming>{1}</AllowIncrementalNaming> | ||
</ContentType>"; | ||
var ctd1 = String.Format(ctdformat, ContentType_IncrementalNamingAllowedName, "true"); | ||
var ctd2 = String.Format(ctdformat, ContentType_IncrementalNamingDisallowedName, "false"); | ||
ContentTypeInstaller.InstallContentType(CarContentType, ctd1, ctd2); | ||
ContentType_IncrementalNamingAllowed = ContentType.GetByName(ContentType_IncrementalNamingAllowedName); | ||
ContentType_IncrementalNamingDisallowed = ContentType.GetByName(ContentType_IncrementalNamingDisallowedName); | ||
} | ||
|
||
/* ================================================================================= TEST CASES */ | ||
|
||
public void ContentNaming_AllowIncrementalNaming_Allowed() | ||
{ | ||
IntegrationTest(() => | ||
{ | ||
InstallContentTypes(); | ||
var testRoot = new SystemFolder(Repository.Root); | ||
testRoot.Save(); | ||
|
||
Content content1, content2; | ||
do | ||
{ | ||
content1 = Content.CreateNew(ContentType_IncrementalNamingAllowedName, testRoot, null); | ||
content2 = Content.CreateNew(ContentType_IncrementalNamingAllowedName, testRoot, null); | ||
} while (content1.Name != content2.Name); | ||
content1.Save(); | ||
content2.Save(); | ||
}); | ||
|
||
} | ||
public void ContentNaming_AllowIncrementalNaming_Disallowed() | ||
{ | ||
IntegrationTest(() => | ||
{ | ||
var thrown = false; | ||
try | ||
{ | ||
InstallContentTypes(); | ||
var testRoot = new SystemFolder(Repository.Root); | ||
testRoot.Save(); | ||
|
||
Content content1, content2; | ||
do | ||
{ | ||
content1 = Content.CreateNew(ContentType_IncrementalNamingDisallowedName, testRoot, null); | ||
content2 = Content.CreateNew(ContentType_IncrementalNamingDisallowedName, testRoot, null); | ||
} while (content1.Name != content2.Name); | ||
content1.Save(); | ||
content2.Save(); | ||
} | ||
catch (NodeAlreadyExistsException) | ||
{ | ||
thrown = true; | ||
} | ||
catch (AggregateException ae) | ||
{ | ||
thrown = ae.InnerException is NodeAlreadyExistsException; | ||
} | ||
if (!thrown) | ||
Assert.Fail("The expected NodeAlreadyExistsException was not thrown."); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters