Beispiel #1
0
 public IHttpActionResult CreateChildInstance(int id, EAV.Store.IStoreInstance instance)
 {
     try
     {
         return(Ok <EAV.Store.IStoreInstance>(instanceClient.CreateChildInstance(instance, ContainerID.GetValueOrDefault(), id)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
        public void CreateChildInstance()
        {
            EAV.Store.Clients.IInstanceStoreClient client = factory.Create <EAV.Store.Clients.IInstanceStoreClient>();
            var dbParentInstance = SelectRandomItem(this.DbContext.Instances);

            EAV.Store.IStoreInstance instance = client.CreateChildInstance(new EAVStoreLibrary.StoreInstance(), dbParentInstance.Container_ID, dbParentInstance.Instance_ID);

            Assert.IsNotNull(instance, "Failed to create instance for container ID {0} and parent instance ID {1}.", dbParentInstance.Container_ID, dbParentInstance.Instance_ID);

            ResetDatabaseContext();

            var dbInstance = this.DbContext.Instances.SingleOrDefault(it => it.Instance_ID == instance.InstanceID);

            Assert.IsNotNull(dbInstance, String.Format("Failed to retrieve instance ID {0} from the database.", instance.InstanceID));

            Assert.IsNotNull(dbInstance.Parent_Instance_ID, "Instance has no parent reference defined when it should.");
        }