public void GetCalendarsViaApiInterface() { MASchemaType maSchemaType = UnitTestControl.Schema[SchemaConstants.Calendar]; ApiInterfaceCalendar u = new ApiInterfaceCalendar("my_customer", maSchemaType, UnitTestControl.TestParameters); BlockingCollection <object> items = new BlockingCollection <object>(); u.GetObjectImportTask(UnitTestControl.MmsSchema, items, CancellationToken.None).Wait(); HashSet <string> dns = new HashSet <string>(); foreach (CSEntryChange item in items.OfType <CSEntryChange>()) { //Assert.AreEqual(MAImportError.Success, item.ErrorCodeImport); //Assert.IsTrue(dns.Add(item.DN)); foreach (AttributeChange c in item.AttributeChanges) { foreach (ValueChange v in c.ValueChanges) { Type t = v.Value.GetType(); if (t != typeof(string) && t != typeof(long)) { Debug.WriteLine($"{c.Name} - {v.Value.GetType()}"); } } } } Assert.AreNotEqual(0, items.Count); }
public void CreateCalendar() { CSEntryChange cs = CSEntryChange.Create(); cs.ObjectModificationType = ObjectModificationType.Add; cs.DN = Guid.NewGuid().ToString(); cs.ObjectType = SchemaConstants.Calendar; cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("name", "test-name")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("buildingId", "testbuilding1")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("capacity", 33L)); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("floorName", "G")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("floorSection", "33B")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("resourceCategory", "CONFERENCE_ROOM")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("resourceDescription", "internal description")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("userVisibleDescription", "user description")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("features", new List <object> { "Test1", "Test2" })); string id = null; try { CSEntryChangeResult result = ExportProcessor.PutCSEntryChange(cs, UnitTestControl.Schema.GetSchema().Types[SchemaConstants.Calendar], UnitTestControl.TestParameters); if (result.ErrorCode != MAExportError.Success) { Assert.Fail(result.ErrorName); } id = result.AnchorAttributes["id"].GetValueAdd <string>(); Thread.Sleep(UnitTestControl.PostGoogleOperationSleepInterval); CalendarResource c = UnitTestControl.TestParameters.ResourcesService.GetCalendar(UnitTestControl.TestParameters.CustomerID, id); Assert.AreEqual("test-name", c.ResourceName); Assert.IsNotNull(c.ResourceEmail); Assert.AreEqual("testbuilding1", c.BuildingId); Assert.AreEqual(33, c.Capacity); Assert.AreEqual("G", c.FloorName); Assert.AreEqual("33B", c.FloorSection); Assert.AreEqual("CONFERENCE_ROOM", c.ResourceCategory); Assert.AreEqual("internal description", c.ResourceDescription); Assert.AreEqual("user description", c.UserVisibleDescription); CollectionAssert.AreEquivalent(new string[] { "Test1", "Test2" }, ApiInterfaceCalendar.GetFeatureNames(c).ToList()); } finally { if (id != null) { UnitTestControl.TestParameters.ResourcesService.DeleteCalendar(UnitTestControl.TestParameters.CustomerID, id); } } }
public void UpdateCalendar() { CalendarResource calendar = new CalendarResource(); calendar.ResourceId = Guid.NewGuid().ToString("n"); calendar.ResourceName = "test-name"; calendar.BuildingId = "testbuilding2"; calendar.Capacity = 9; calendar.FloorName = "G"; calendar.FloorSection = "39b"; calendar.ResourceCategory = "OTHER"; calendar.ResourceDescription = "internal description 1"; calendar.UserVisibleDescription = "my description 2"; calendar.FeatureInstances = new List <FeatureInstance>() { new FeatureInstance() { Feature = new Feature() { Name = "Test1" } }, new FeatureInstance() { Feature = new Feature() { Name = "Test2" } }, }; UnitTestControl.TestParameters.ResourcesService.AddCalendar(UnitTestControl.TestParameters.CustomerID, calendar); CSEntryChange cs = CSEntryChange.Create(); cs.ObjectModificationType = ObjectModificationType.Update; cs.DN = "*****@*****.**"; cs.ObjectType = SchemaConstants.Calendar; cs.AnchorAttributes.Add(AnchorAttribute.Create("id", calendar.ResourceId)); cs.AttributeChanges.Add(AttributeChange.CreateAttributeUpdate("buildingId", new List <ValueChange>() { ValueChange.CreateValueAdd("testbuilding1") })); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("capacity", 33L)); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("floorName", "G")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("floorSection", "33B")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("resourceCategory", "CONFERENCE_ROOM")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("resourceDescription", "internal description")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeReplace("userVisibleDescription", "user description")); cs.AttributeChanges.Add(AttributeChange.CreateAttributeUpdate("features", new List <ValueChange>() { ValueChange.CreateValueAdd("Test3"), ValueChange.CreateValueDelete("Test1"), })); string id = calendar.ResourceId; try { CSEntryChangeResult result = ExportProcessor.PutCSEntryChange(cs, UnitTestControl.Schema.GetSchema().Types[SchemaConstants.Calendar], UnitTestControl.TestParameters); if (result.ErrorCode != MAExportError.Success) { Assert.Fail(result.ErrorName); } Thread.Sleep(UnitTestControl.PostGoogleOperationSleepInterval); CalendarResource c = UnitTestControl.TestParameters.ResourcesService.GetCalendar(UnitTestControl.TestParameters.CustomerID, id); Assert.AreEqual(cs.DN, "*****@*****.**"); Assert.AreEqual("test-name", c.ResourceName); Assert.AreEqual("testbuilding1", c.BuildingId); Assert.AreEqual(33, c.Capacity); Assert.AreEqual("G", c.FloorName); Assert.AreEqual("33B", c.FloorSection); Assert.AreEqual("CONFERENCE_ROOM", c.ResourceCategory); Assert.AreEqual("internal description", c.ResourceDescription); Assert.AreEqual("user description", c.UserVisibleDescription); CollectionAssert.AreEquivalent(new string[] { "Test2", "Test3" }, ApiInterfaceCalendar.GetFeatureNames(c).ToList()); } finally { if (id != null) { UnitTestControl.TestParameters.ResourcesService.DeleteCalendar(UnitTestControl.TestParameters.CustomerID, id); } } }