Example #1
0
        public void ContentTemplate_GetNewItemNodes()
        {
            CreatePlayGround();

            Assert.IsTrue(GenericScenario.GetNewItemNodes(TestList, new ContentType[0]).Count() == 0, "#0 new item list is not empty");

            var itemsForList1 = GenericScenario.GetNewItemNodes(TestList).ToList();

            Assert.IsTrue(itemsForList1.Count(ct => ct.Path.Equals(_fileTemplate2.Path)) == 1, "#1 " + _fileTemplate2.Path + " not found");
            Assert.IsTrue(itemsForList1.Count(ct => ct.Path.Equals(_fileGlobalTemplate1.Path)) == 0, "#2 " + _fileGlobalTemplate1.Path + " found");

            var itemsForList2 = GenericScenario.GetNewItemNodes(_list2).ToList();

            Assert.IsTrue(itemsForList2.Count(ct => ct.Path.Equals(_fileTemplate2.Path)) == 0, "#3 " + _fileTemplate2.Path + " found");
            Assert.IsTrue(itemsForList2.Count(ct => ct.Path.Equals(_fileTemplate1.Path)) == 1, "#4 " + _fileTemplate1.Path + " not found");

            var itemsForWorkspace = GenericScenario.GetNewItemNodes(TestWorkspace).ToList();

            Assert.IsTrue(itemsForWorkspace.Count(ct => ct.Path.Equals(_listTemplate1.Path)) == 1, "#5 " + _listTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 0, "#6 " + _listGlobalTemplate1.Path + " found");

            var itemsForWorkspace2 = GenericScenario.GetNewItemNodes(TestWorkspace2).ToList();

            Assert.IsTrue(itemsForWorkspace2.Count(ct => ct.Path.Equals(_fileTemplate1.Path)) == 1, "#7 " + _fileTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace2.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 1, "#8 " + _listGlobalTemplate1.Path + " not found");

            var itemsForWorkspace3 = GenericScenario.GetNewItemNodes(TestWorkspace3).ToList();

            Assert.IsTrue(itemsForWorkspace3.Count(ct => ct.Path.Equals(_fileGlobalTemplate1.Path)) == 1, "#9 " + _fileGlobalTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace3.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 1, "#10 " + _listGlobalTemplate1.Path + " not found");
        }
Example #2
0
File: Program.cs Project: Ouay/MVP
        static void Main(string[] args)
        {
            GPIOControl.SetLed(GPIOControl.Mode.StandBy);
            Thread.Sleep(10);
            GenericScenario scenario = new GenericScenario();

            scenario.Start();
        }
Example #3
0
        /// <summary>
        /// Transforme le scénario en scénario générique
        /// <summary>
        public GenericScenario ToGeneric()
        {
            GenericScenario current = new GenericScenario();

            current.Name      = base.Name;
            current.Id        = base.Id;
            current.IsPlaying = base.IsPlaying;
            current.Steps     = this.GenericSteps;
            current.Time      = base.Time;

            return(current);
        }
Example #4
0
        // ================================================================================================ Methods

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            UITools.AddScript(UITools.ClientScriptConfigurations.SNWallPath);

            UITools.AddPickerCss();
            UITools.AddScript(UITools.ClientScriptConfigurations.SNPickerPath);

            // get items for content types drowpdown in dropbox
            var gc       = new GenericContent(this.ContextNode, "Folder");
            var newItems = GenericScenario.GetNewItemNodes(gc, ContentType.GetContentTypes());

            string jsonData;

            using (var s = new MemoryStream())
            {
                var workData = newItems.Select(n => new ContentTypeItem {
                    value = n.Name, label = n.DisplayName
                }).OrderBy(n => n.label);
                var serializer = new DataContractJsonSerializer(typeof(ContentTypeItem[]));
                serializer.WriteObject(s, workData.ToArray());
                s.Flush();
                s.Position = 0;
                using (var sr = new StreamReader(s))
                {
                    jsonData = sr.ReadToEnd();
                }
            }

            UITools.RegisterStartupScript("initdropboxautocomplete", string.Format("SN.Wall.initDropBox({0})", jsonData), this.Page);

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }
        }
Example #5
0
 public ScenarioPlayer()
 {
     Trace.WriteDebug("Init ScenarioPlayer");
     //Initialisation           
     isCrashed = false;
     crashMsg = String.Empty;
     beginDatetime = DateTime.MinValue;
     scenarioToPlay = new GenericScenario();
     scenarioDatas = String.Empty;
     
     if (threadStepPlayer == null && !(isCrashed))
     {
         threadStepPlayer = new Thread(new ThreadStart(PlayScenario));
         threadStepPlayer.Start();
     }
     //PlayScenario();
 }
Example #6
0
        //Fonction ReadXMLScenario()               
        private bool ReadXMLScenario(String _datas)
        {
            bool error = false;

            //On désérialise le fichier XML pour obtenir l'objet GenericScenario
            if (_datas != null)
            {
                try
                {
                    XmlSerializer s = new XmlSerializer(typeof(GenericScenario));
                    byte[] buf = System.Text.Encoding.Unicode.GetBytes(_datas);
                    MemoryStream ms = new MemoryStream(buf);
                    scenarioToPlay = (GenericScenario)s.Deserialize((Stream)ms);

                    //Envois d'un Acquittement OK
                    MainEntry.server.SendAck(OrderResult.OK);
                }
                catch (Exception e)
                {
                    Trace.WriteError("Impossible de lire le fichier XML décrivant le scenario, format incorect");
                    error = true;
                }
            }
            else
            {
                Trace.WriteError("Le scenario n'a pas été reçu");
                error = true;
            }

            if (!error)
            {
                
                return true;
            }

            else
            {
                //Envois d'un Acquittement KO
                MainEntry.server.SendAck(OrderResult.KO);
                return false  ;
            }
        }