private void t03_Types(CMISTestSystem con) { initializeClient(con); CMISType root = cmisClient.GetRootType(); Assert.AreEqual(con.RootType, root.Id); CMISType type = cmisClient.GetTypeFromId(con.TypesType); List <CMISProperty> props = cmisClient.GetPropertyDefinitions(type); Assert.AreEqual(con.NumberOfProperties, props.Count); foreach (CMISProperty p in con.ExpectedProperties) { CMISProperty p1 = props.Where(n => n.Id == p.Id).First(); Assert.AreEqual(p.DisplayName, p1.DisplayName); Assert.AreEqual(p.Type, p1.Type); } }
public void T09_PropertyConverter() { CultureInfo ci = new CultureInfo("en-US"); object o; CMISProperty prop = new CMISProperty(); prop.Type = CMISClientType.Integer; SIEEField field = new SIEEField(); field.Value = "42"; List <string> valueList = new List <string>() { "2", "", "3", null }; field.ValueList = valueList; // Default, take value o = prop.ConvertValue(field, ci); Assert.IsTrue(o is Int32); Assert.AreEqual(42, o); // IsMulti alone, no list prop.IsMulti = true; field.ValueList = new List <string>(); o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(1, (o as List <Int32>).Count); Assert.AreEqual(42, (o as List <Int32>)[0]); // IsMulti with list field.ValueList = valueList; o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(1, (o as List <Int32>).Count); Assert.AreEqual(42, (o as List <Int32>)[0]); // Now create list field.Cardinality = -1; o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(4, (o as List <Int32>).Count); Assert.AreEqual(2, (o as List <Int32>)[0]); Assert.AreEqual(0, (o as List <Int32>)[1]); Assert.AreEqual(3, (o as List <Int32>)[2]); Assert.AreEqual(0, (o as List <Int32>)[3]); // Check Boolean prop.IsMulti = false; prop.Type = CMISClientType.Boolean; field.Value = "true"; o = prop.ConvertValue(field, ci); Assert.AreEqual(true, o); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual(false, o); // Check DateTime prop.IsMulti = false; prop.Type = CMISClientType.DateTime; DateTime dt = DateTime.Now; field.Value = dt.ToString(ci); o = prop.ConvertValue(field, ci); Assert.AreEqual(dt.ToString(), o.ToString()); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual(dt.ToString(), o.ToString()); // Check Decimal prop.IsMulti = false; prop.Type = CMISClientType.Decimal; field.Value = "5.6"; o = prop.ConvertValue(field, ci); Assert.AreEqual((Decimal)5.6, o); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual((Decimal)0.0, o); }
public void T02_BasicExport() { CMISViewModel vm = getInitializedViewModel(); vm.CMISSettings.SelectedCultureInfoName = "en-US"; StoreDocumentResult expectedtResult = StoreDocumentResult.DefaultResult(); CMISClientMock cmisClient = new CMISClientMock(); CMISExport export = new CMISExport(cmisClient); SIEEBatch batch = createBatch(expectedtResult.Filename, expectedtResult.DocName); SIEEFieldlist fieldlist = batch[0].Fieldlist; // Default document export vm.LoadPropertiesHandler(); Assert.IsTrue(vm.TT.PropertiesLoaded); Assert.AreEqual(6, vm.TT.Properties.Count); export.Init(vm.Settings); export.ExportBatch(vm.Settings, batch); Assert.IsTrue(batch[0].Succeeded); expectedtResult.Compare(cmisClient.SDR); foreach (CMISProperty p in vm.TT.Properties) { p.Selected = true; object objectValue; string stringValue; switch (p.Type) { case CMISClientType.Boolean: stringValue = "true"; objectValue = true; break; case CMISClientType.Integer: stringValue = "4711"; objectValue = 4711; break; case CMISClientType.Decimal: stringValue = "1.8"; objectValue = 1.8M; break; case CMISClientType.DateTime: stringValue = "11.03.2017"; objectValue = DateTime.Parse(stringValue, new CultureInfo("en-US")); break; default: objectValue = stringValue = "Some string"; break; } fieldlist.Add(new SIEEField(p.Id, p.Id, stringValue)); expectedtResult.Properties[p.Id] = objectValue; export.Init(vm.Settings); export.ExportBatch(vm.Settings, batch); Assert.IsTrue(batch[0].Succeeded); expectedtResult.Compare(cmisClient.SDR); if (p.Type != CMISClientType.String) { fieldlist.Where(n => n.ExternalId == p.Id).First().Value = "Illegal value"; export.Init(vm.Settings); export.ExportBatch(vm.Settings, batch); Assert.IsFalse(batch[0].Succeeded); } expectedtResult.Compare(cmisClient.SDR); fieldlist.Remove(fieldlist.Where(n => n.ExternalId == p.Id).First()); expectedtResult.Properties.Remove(p.Id); } CMISProperty pror = vm.TT.Properties.Where(n => n.Type == CMISClientType.Decimal).First(); pror.Selected = true; fieldlist.Add(new SIEEField(pror.Id, pror.Id, "1,8")); expectedtResult.Properties[pror.Id] = 1.8M; vm.CMISSettings.SelectedCultureInfoName = "de-DE"; export.Init(vm.Settings); export.ExportBatch(vm.Settings, batch); Assert.IsTrue(batch[0].Succeeded); expectedtResult.Compare(cmisClient.SDR); }