private ContentAccessor DatetimeTest(string contentTypeName)
{
DateTime originalValue;
DateTime currentValue;
DateTime handlerValue;
string fieldName = "DateTime";
DateTime defaultValue = DateTime.MinValue;
DateTime testValue = DateTime.Parse("2008-06-04 12:34:56");
DateTime defaultHandlerValue = defaultValue;
DateTime testHandlerValue = testValue;
Content content = Content.CreateNew(contentTypeName, Repository.Root, "FieldTest");
ContentAccessor contentAcc = new ContentAccessor(content);
originalValue = (DateTime)content.Fields[fieldName].OriginalValue;
currentValue = (DateTime)content[fieldName];
handlerValue = (DateTime)content.ContentHandler[fieldName];
Assert.IsTrue(ItIsDateTimeDefault(originalValue), contentTypeName + "####1: Storage2: DateTime default value");
Assert.IsTrue(ItIsDateTimeDefault(currentValue), contentTypeName + "#2");
Assert.IsTrue(ItIsDateTimeDefault(handlerValue), contentTypeName + "#3");
content[fieldName] = testValue;
originalValue = (DateTime)content.Fields[fieldName].OriginalValue;
currentValue = (DateTime)content[fieldName];
Assert.IsTrue(ItIsDateTimeDefault(originalValue), contentTypeName + "#4");
Assert.IsTrue(currentValue == testValue, contentTypeName + "#5");
contentAcc.SaveFields();
originalValue = (DateTime)content.Fields[fieldName].OriginalValue;
currentValue = (DateTime)content[fieldName];
handlerValue = (DateTime)content.ContentHandler[fieldName];
Assert.IsTrue(originalValue == testValue, contentTypeName + "#6");
Assert.IsTrue(currentValue == testValue, contentTypeName + "#7");
Assert.IsTrue(handlerValue == testHandlerValue, contentTypeName + "#8");
content[fieldName] = defaultValue;
originalValue = (DateTime)content.Fields[fieldName].OriginalValue;
currentValue = (DateTime)content[fieldName];
Assert.IsTrue(originalValue == testValue, contentTypeName + "#9");
Assert.IsTrue(currentValue == defaultValue, contentTypeName + "#10");
contentAcc.SaveFields();
originalValue = (DateTime)content.Fields[fieldName].OriginalValue;
currentValue = (DateTime)content[fieldName];
handlerValue = (DateTime)content.ContentHandler[fieldName];
Assert.IsTrue(originalValue == defaultValue, contentTypeName + "#11");
Assert.IsTrue(currentValue == defaultValue, contentTypeName + "#12");
Assert.IsTrue(handlerValue == defaultHandlerValue, contentTypeName + "#13");
return contentAcc;
}