Ejemplo n.º 1
0
        public static SupportedEnvironment Add(SupportedEnvironment supportedEnvironment)
        {
            using (ES1AutomationEntities context = new ES1AutomationEntities())
            {
                int environmentId = 0;
                try
                {
                    environmentId = (from e in context.SupportedEnvironments select e.EnvironmentId).Max() + 1;
                }
                catch (Exception e)
                {
                    ATFEnvironment.Log.logger.Error(e);
                    environmentId = 1;
                }
                if (SupportedEnvironment.GetSupportedEnvironmentById(environmentId) != null)
                {
                    return null;
                }

                supportedEnvironment.EnvironmentId = environmentId;
                SupportedEnvironment supportEnvironmentAdded = context.SupportedEnvironments.Add(supportedEnvironment);
                context.SaveChanges();
                return supportEnvironmentAdded;
            }
        }
Ejemplo n.º 2
0
 public static void Delete(SupportedEnvironment supportedEnvironment)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         context.SupportedEnvironments.Attach(supportedEnvironment);
         context.SupportedEnvironments.Remove(supportedEnvironment);
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public static TestEnvironment GetAvalibleStaticSUT4SupportedEnvironment(SupportedEnvironment supportEnvironment)
 {
     TestEnvironmentConfigHelper config = new TestEnvironmentConfigHelper(supportEnvironment.Config);
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         foreach (TestEnvironment environment in context.TestEnvironments.Where(e => e.Type == EnvironmentCreateType.Static && e.Status == (int)EnvironmentStatus.Disposed && e.ProviderId == supportEnvironment.ProviderId))
         {
             TestEnvironmentConfigHelper eConfig = new TestEnvironmentConfigHelper(environment.Config);
             if (eConfig.Type == EnvironmentType.SUTAlone && eConfig.SUTConfiguration.Name == config.SUTConfiguration.Name)
             {
                 return environment;
             }
         }
         return null;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="SupportedEnvironment"/> converted from <see cref="SupportedEnvironmentDTO"/>.</param>
partial         static void OnEntity(this SupportedEnvironmentDTO dto, SupportedEnvironment entity);
Ejemplo n.º 5
0
        /// <summary>
        /// Converts this instance of <see cref="SupportedEnvironmentDTO"/> to an instance of <see cref="SupportedEnvironment"/>.
        /// </summary>
        /// <param name="dto"><see cref="SupportedEnvironmentDTO"/> to convert.</param>
        public static SupportedEnvironment ToEntity(this SupportedEnvironmentDTO dto)
        {
            if (dto == null) return null;

            var entity = new SupportedEnvironment();

            entity.EnvironmentId = dto.EnvironmentId;
            entity.Name = dto.Name;
            entity.Description = dto.Description;
            entity.Config = dto.Config;
            entity.ProviderId = dto.ProviderId;
            dto.OnEntity(entity);

            return entity;
        }