Ejemplo n.º 1
0
        public void ShouldReturnFalseWhenDateIsNotInPeriod()
        {
            var period = new Period(2020, 2);

            Assert.IsFalse(period.Contains(new DateTime(2020, 1, 31)));
            Assert.IsFalse(period.Contains(new DateTime(2020, 1, 31, 23, 59, 59)));
            Assert.IsFalse(period.Contains(new DateTime(2020, 3, 1)));
        }
Ejemplo n.º 2
0
        public void PeriodIsRightOpen()
        {
            var period = new Period(10.01.of2009(), 20.01.of2009());

            Assert.IsFalse(period.Contains(9.01.of2009()));
            Assert.IsTrue(period.Contains(10.01.of2009()));
            Assert.IsTrue(period.Contains(19.01.of2009()));
            Assert.IsFalse(period.Contains(20.01.of2009()));
        }
Ejemplo n.º 3
0
        public void ShouldReturnTrueWhenDateIsInPeriod()
        {
            var period = new Period(2020, 2);

            Assert.IsTrue(period.Contains(new DateTime(2020, 2, 1)));
            Assert.IsTrue(period.Contains(new DateTime(2020, 2, 14)));
            Assert.IsTrue(period.Contains(new DateTime(2020, 2, 15)));
            Assert.IsTrue(period.Contains(new DateTime(2020, 2, 29, 23, 59, 59)));
        }
Ejemplo n.º 4
0
        public void ContainSamePeriod()
        {
            Period period   = new Period(DateTime.Now, DateTime.Now);
            bool   contains = period.Contains(period);

            Assert.IsTrue(contains);
        }
Ejemplo n.º 5
0
        public void NotContainsOvelapPeriod()
        {
            Period smallPeriod = new Period(DateTime.Now, DateTime.Now.AddHours(2));
            Period bigPeriod   = new Period(DateTime.Now.AddHours(-1), DateTime.Now.AddHours(1));

            bool contains = bigPeriod.Contains(smallPeriod);

            Assert.IsFalse(contains);
        }
Ejemplo n.º 6
0
        public void ContainPeriod()
        {
            Period smallPeriod = new Period(DateTime.Now.AddHours(-1), DateTime.Now.AddHours(1));
            Period bigPeriod   = new Period(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));

            bool contains = bigPeriod.Contains(smallPeriod);

            Assert.IsTrue(contains);
        }
Ejemplo n.º 7
0
        public bool TimeDataUpdate(DataPoint Data)
        {
            if (!DataPeriod.Contains(Data.Timestamp))
            {
                return(false);
            }

            Target.TimeDataUpdate(this, Data);

            return(true);
        }
Ejemplo n.º 8
0
        public void Should_Verify_Date_Is_Not_In_Period()
        {
            // SETUP
            var notInRangeDate = new DateTime(2018, 05, 21, 10, 00, 00);

            var startingDate = new DateTime(2018, 10, 01);
            var endingDate   = new DateTime(2018, 10, 30);
            var period       = new Period(startingDate, endingDate);

            // RUN
            var isSpecificDateContainedInPeriod = period.Contains(notInRangeDate);

            // ASSERT
            Check.That(isSpecificDateContainedInPeriod).IsFalse();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Добавление канала с указанным адресом
        /// </summary>
        private static void AddChannel(XmlDocument xmlDoc, TreeNode node,
                                       XmlElement subtypeElm, long channelId)
        {
            string     prefix     = "channels";
            string     nsChannels = "http://brestmilk.by/channels/";
            XmlElement channel    = xmlDoc.CreateElement(prefix, "channel",
                                                         nsChannels);

            subtypeElm.AppendChild(channel);
            XmlElement channelElm = xmlDoc.CreateElement(prefix, "id",
                                                         nsChannels);

            channelElm.InnerText = channelId.ToString();
            channel.AppendChild(channelElm);

            string subtypeName   = subtypeElm.ParentNode.ChildNodes[6].InnerText;
            bool   needSetPeriod = Period.Contains(subtypeName);

            if (needSetPeriod)
            {
                channelElm = xmlDoc.CreateElement(prefix, "requesttype",
                                                  nsChannels);
                channelElm.InnerText = "0";
                channel.AppendChild(channelElm);
                channelElm = xmlDoc.CreateElement(prefix, "requestperiod",
                                                  nsChannels);
                channelElm.InnerText = GetRequestPeriodForTag(subtypeName);
            }
            else
            {
                channelElm = xmlDoc.CreateElement(prefix, "requesttype",
                                                  nsChannels);
                channelElm.InnerText = "1";
                channel.AppendChild(channelElm);
                channelElm = xmlDoc.CreateElement(prefix, "requestperiod",
                                                  nsChannels);
                channelElm.InnerText = "1";
            }

            channel.AppendChild(channelElm);
            channelElm           = xmlDoc.CreateElement(prefix, "enabled", nsChannels);
            channelElm.InnerText = "-1";
            channel.AppendChild(channelElm);
            channelElm           = xmlDoc.CreateElement(prefix, "descr", nsChannels);
            channelElm.InnerText = node.Text;
            channel.AppendChild(channelElm);
            channelElm = xmlDoc.CreateElement(prefix, "delta", nsChannels);

            if (needSetPeriod)
            {
                channelElm.InnerText = GetDeltaForTag(subtypeName);
            }
            else
            {
                channelElm.InnerText = "0";
            }

            channel.AppendChild(channelElm);
            channelElm           = xmlDoc.CreateElement(prefix, "apptime", nsChannels);
            channelElm.InnerText = "0";
            channel.AppendChild(channelElm);
            channelElm = xmlDoc.CreateElement(prefix, "protocol", nsChannels);

            bool needSetProtocol = GetNeedProtocolCondition(subtypeName, node);

            if (needSetProtocol)
            {
                channelElm.InnerText = "-1";
            }
            else
            {
                channelElm.InnerText = "0";
            }

            channel.AppendChild(channelElm);
            channelElm = xmlDoc.CreateElement(prefix, "transexprin",
                                              nsChannels);
            channelElm.AppendChild(xmlDoc.CreateCDataSection(""));
            channel.AppendChild(channelElm);
            channelElm = xmlDoc.CreateElement(prefix, "transexprout",
                                              nsChannels);
            channelElm.AppendChild(xmlDoc.CreateCDataSection(""));
            channel.AppendChild(channelElm);
            channelElm = xmlDoc.CreateElement(prefix, "channel_parameters",
                                              nsChannels);
            string nsParams = "http://brestmilk.by/parameters/";

            channelElm.SetAttribute("xmlns:parameters", nsParams);

            if (node.Text.Contains("UP_TIME") ||
                node.Text.Contains("CMD_ANSWER"))
            {
                AddChannelAtribute(xmlDoc, channelElm, "IsString");
            }
            channel.AppendChild(channelElm);
        }
Ejemplo n.º 10
0
 private IQueryable <Transaction> GetJournalsApplyingToPeriod(ITransactionRepository repository)
 {
     return(repository.GetTransactions().Where(x => Period.Contains(x.TransactionDate)));
 }