public void DataTypeEditorControllerTests_DataType_Create()
{
//Arrange
//create data type in persistence layer
var propEditor = new MandatoryPropertyEditor();
var dataTypeEntity = HiveModelCreationHelper.CreateAttributeType("test", "Test", "");
dataTypeEntity.RenderTypeProvider = propEditor.Id.ToString();
var controller = new DataTypeEditorController(GetBackOfficeRequestContext());
controller.InjectDependencies(new Dictionary<string, string>(), new Dictionary<string, string>
{
{"Name", "Hello World"},
{"PropertyEditorId", FixedPropertyEditors.GetPropertyEditorDefinitions().First().Metadata.Id.ToString()},
{ "submit.Save", "Save"} //set save flag
}, GetBackOfficeRequestContext(), false);
//Act
var result = controller.CreateForm();
//Assert
Assert.IsTrue(result is RedirectToRouteResult);
//get the new id from the route values
var newId = ((RedirectToRouteResult)result).RouteValues["id"];
Assert.AreEqual(typeof(HiveId), newId.GetType());
using (var uow = RebelApplicationContext.Hive.OpenReader<IContentStore>())
{
var latestEntity = uow.Repositories.Schemas.Get<AttributeType>((HiveId)newId);
Assert.AreEqual("Hello World", latestEntity.Name.Value);
Assert.AreEqual(FixedPropertyEditors.GetPropertyEditorDefinitions().First().Metadata.Id.ToString(), latestEntity.RenderTypeProvider);
Assert.IsTrue(DateTimeOffset.UtcNow.Subtract(latestEntity.UtcCreated) < new TimeSpan(0, 1, 0));
}
}