Fixes: U4-4368 Cannot insert the value NULL into column 'name' when creating new relation type from API

This commit is contained in:
Shannon
2014-03-17 13:21:17 +11:00
parent d1d54d8e84
commit f642a7fd63
4 changed files with 45 additions and 1 deletions

View File

@@ -21,9 +21,18 @@ namespace Umbraco.Core.Models
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias)
{
Mandate.ParameterNotNullOrEmpty(@alias, "alias");
_childObjectType = childObjectType;
_parentObjectType = parentObjectType;
_alias = alias;
Name = _alias;
}
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias, string name)
:this(childObjectType, parentObjectType, @alias)
{
Mandate.ParameterNotNullOrEmpty(name, "name");
Name = name;
}
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<RelationType, string>(x => x.Name);

View File

@@ -14,7 +14,7 @@ using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
/// <summary>
/// <summary>
/// Tests covering all methods in the ContentService class.
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.

View File

@@ -0,0 +1,34 @@
using System;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Models;
namespace Umbraco.Tests.Services
{
[TestFixture, RequiresSTA]
public class RelationServiceTests : BaseServiceTest
{
[SetUp]
public override void Initialize()
{
base.Initialize();
}
[TearDown]
public override void TearDown()
{
base.TearDown();
}
[Test]
public void Can_Create_RelationType_Without_Name()
{
var rs = ServiceContext.RelationService;
var rt = new RelationType(new Guid(Constants.ObjectTypes.Document), new Guid(Constants.ObjectTypes.Document), "repeatedEventOccurence");
Assert.DoesNotThrow(() => rs.Save(rt));
Assert.AreEqual(rt.Name, "repeatedEventOccurence");
}
}
}

View File

@@ -234,6 +234,7 @@
<Compile Include="Services\MemberTypeServiceTests.cs" />
<Compile Include="Services\PackagingServiceTests.cs" />
<Compile Include="Services\PerformanceTests.cs" />
<Compile Include="Services\RelationServiceTests.cs" />
<Compile Include="Services\UserServiceTests.cs" />
<Compile Include="TestHelpers\BaseSeleniumTest.cs" />
<Compile Include="Integration\InstallPackage.cs" />