public void CreateDuplicateAttribute_Data_Name() { EAV.Store.Clients.IAttributeStoreClient client = factory.Create <EAV.Store.Clients.IAttributeStoreClient>(); int containerID = SelectRandomItem(this.DbContext.Containers).Context_ID; string attributeName = Guid.NewGuid().ToString(); EAV.Store.IStoreAttribute attribute = client.CreateAttribute(new EAVStoreLibrary.StoreAttribute() { Name = attributeName, DataName = attributeName.ToUpper(), DisplayText = attributeName + ":", DataType = EAV.EAVDataType.String, IsKey = true, Sequence = rng.Next(), VariableUnits = true, }, containerID); Assert.IsNotNull(attribute, "Failed to create attribute with name '{0}' for container ID {1}.", attributeName, containerID); client.CreateAttribute(new EAVStoreLibrary.StoreAttribute() { Name = attributeName + "1", DataName = attributeName.ToUpper(), DisplayText = attributeName + ":", DataType = EAV.EAVDataType.String, IsKey = true, Sequence = rng.Next(), VariableUnits = true, }, containerID); Assert.Fail("Failed to throw exception creating attribute with duplicate data name."); }
public void CreateAttribute() { EAV.Store.Clients.IAttributeStoreClient client = factory.Create <EAV.Store.Clients.IAttributeStoreClient>(); int containerID = SelectRandomItem(this.DbContext.Containers).Context_ID; string attributeName = Guid.NewGuid().ToString(); EAV.Store.IStoreAttribute attribute = client.CreateAttribute(new EAVStoreLibrary.StoreAttribute() { Name = attributeName, DataName = attributeName.ToUpper(), DisplayText = attributeName + ":", DataType = EAV.EAVDataType.String, IsKey = true, Sequence = rng.Next(), VariableUnits = true, }, containerID); Assert.IsNotNull(attribute, "Failed to create attribute with name '{0}' for container ID {1}.", attributeName, containerID); ResetDatabaseContext(); var dbAttribute = this.DbContext.Attributes.SingleOrDefault(it => it.Attribute_ID == attribute.AttributeID); Assert.IsNotNull(dbAttribute, String.Format("Failed to retrieve attribute ID {0} from the database.", attribute.AttributeID)); Assert.AreEqual(attribute.Name, dbAttribute.Name, "Property 'Name' was not created correctly."); Assert.AreEqual(attribute.DataName, dbAttribute.Data_Name, "Property 'DataName' was not created correctly."); Assert.AreEqual(attribute.DisplayText, dbAttribute.Display_Text, "Property 'DisplayText' was not created correctly."); Assert.AreEqual(attribute.DataType.ToString(), dbAttribute.Data_Type.Name, "Property 'DataType' was not created correctly."); Assert.AreEqual(attribute.IsKey, dbAttribute.Is_Key, "Property 'IsKey' was not created correctly."); Assert.AreEqual(attribute.Sequence, dbAttribute.Sequence, "Property 'Sequence' was not created correctly."); Assert.AreEqual(attribute.VariableUnits, dbAttribute.Variable_Units, "Property 'VariableUnits' was not created correctly."); }
public IHttpActionResult CreateAttribute(int id, EAV.Store.IStoreAttribute attribute) { try { return(Ok <EAV.Store.IStoreAttribute>(attributeClient.CreateAttribute(attribute, id))); } catch (Exception ex) { return(InternalServerError(ex)); } }