Exemplo n.º 1
0
        public JobnetData ExtractData(IUnit jobnet)
        {
            var data = new JobnetData();

            data.FullName = jobnet.FullName;
            data.Comment  = jobnet.Comment;
            data.Size     = jobnet.ItSelfAndDescendants().Count();

            var edParam = jobnet.Parameters.FirstOrDefault("ed");

            if (edParam != null)
            {
                data.EdParam = EdParamData.Create(edParam.Values[0].StringValue);
            }

            var fdParam = jobnet.Parameters.FirstOrDefault("fd");

            if (fdParam != null)
            {
                data.FdParam = FdParamData.Create(fdParam.Values[0].StringValue);
            }

            data.RunCondition = RunConditionData.Create(jobnet.
                                                        Children(UnitType.RunCondition).TheirChildren().Select(x => x.Type));

            data.HasSubSchedules = jobnet.Descendants(UnitType.Jobnet).HasParameter("sd").Any();

            foreach (var rule in ExtractRuleData(jobnet))
            {
                data.ScheduleRules.Add(rule);
            }

            return(data);
        }
        public void Create_Case01_yyyymmdd()
        {
            // Arrange
            // Act
            var pd = EdParamData.Create("2018/06/15");

            // Assert
            Assert.That(pd.RawData, Is.EqualTo("2018/06/15"));
            Assert.That(pd.Year, Is.EqualTo(2018));
            Assert.That(pd.Month, Is.EqualTo(6));
            Assert.That(pd.Day, Is.EqualTo(15));
            Assert.That(pd.ToString(), Is.EqualTo("2018年6月15日"));
        }