コード例 #1
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_TimingToIndex_Test1()
        {
            //Arrange
            var Timing = new Timing();

            DateTimeOffset?ExpectedLow  = new DateTimeOffset(1974, 12, 25, 10, 00, 00, new TimeSpan(-5, 00, 00)).ToUniversalTime();
            DateTimeOffset?ExpectedHigh = new DateTimeOffset(1974, 12, 26, 11, 10, 00, new TimeSpan(-5, 00, 00)).ToUniversalTime();

            Timing.EventElement = new System.Collections.Generic.List <FhirDateTime>();
            var EventStart1 = new FhirDateTime(new DateTimeOffset(1974, 12, 26, 11, 00, 00, new TimeSpan(-5, 00, 00)));
            var EventStart2 = new FhirDateTime(ExpectedLow.Value);

            Timing.EventElement.Add(EventStart1);
            Timing.EventElement.Add(EventStart2);

            Timing.Repeat              = new Timing.RepeatComponent();
            Timing.Repeat.Duration     = new decimal(10.0);
            Timing.Repeat.DurationUnit = Timing.UnitsOfTime.Min;

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(Timing);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #2
0
        public void Test_Date_DateTimeIndexSetter_GoodFormat_YearOnly()
        {
            //Arrange
            var           Date  = new Date("1974");
            DateTimeIndex Index = new DateTimeIndex();

            //Act
            IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(Date, Index);

            //Assert
            Assert.AreEqual(new DateTimeOffset(1974, 01, 01, 00, 00, 00, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now)), Index.DateTimeOffset);
        }
コード例 #3
0
        public void Test_Instant_DateTimeIndexSetter_Instant_IsNull()
        {
            //Arrange
            Instant       Instant = null;
            DateTimeIndex Index   = new DateTimeIndex();

            //Act
            ActualValueDelegate <DateTimeIndex> testDelegate = () => IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(Instant, Index) as DateTimeIndex;

            //Assert
            Assert.That(testDelegate, Throws.TypeOf <ArgumentNullException>());
        }
コード例 #4
0
        public void Test_Instant_DateTimeIndexSetter_InstantValue_IsNull()
        {
            //Arrange
            var           Instant = new Instant(null);
            DateTimeIndex Index   = new DateTimeIndex();

            //Act
            Index = IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(Instant, Index) as DateTimeIndex;

            //Assert
            Assert.IsNull(Index);
        }
コード例 #5
0
        public void Test_Instant_DateTimeIndexSetter_GoodFormat()
        {
            //Arrange
            var           Instant = new Instant(new DateTimeOffset(1974, 12, 25, 14, 35, 45, new TimeSpan(-05, 00, 00)));
            DateTimeIndex Index   = new DateTimeIndex();

            //Act
            IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(Instant, Index);

            //Assert
            Assert.AreEqual(new DateTimeOffset(1974, 12, 25, 14, 35, 45, new TimeSpan(-05, 00, 00)), Index.DateTimeOffset);
        }
コード例 #6
0
        public void Test_Date_DateTimeIndexSetter_BadFormat()
        {
            //Arrange
            var           Date  = new Date("25-12-1974");
            DateTimeIndex Index = new DateTimeIndex();

            //Act
            ActualValueDelegate <DateTimeIndex> testDelegate = () => IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(Date, Index) as DateTimeIndex;

            //Assert
            Assert.That(testDelegate, Throws.TypeOf <FormatException>());
        }
コード例 #7
0
        public void Test_FhirDateTime_DateTimeIndexSetter_GoodFormat()
        {
            //Arrange
            var           FhirDateTime = new FhirDateTime("1974-12-25T14:35:45-05:00");
            DateTimeIndex Index        = new DateTimeIndex();

            //Act
            IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(FhirDateTime, Index);

            //Assert
            Assert.AreEqual(new DateTimeOffset(1974, 12, 25, 14, 35, 45, new TimeSpan(-05, 00, 00)), Index.DateTimeOffset);
        }
コード例 #8
0
        public void Test_FhirString_DateTimeIndexSetter_DateTime_GoodFormat_Milli_ZuluTime()
        {
            //Arrange
            var           FhirString = new FhirString("1974-12-25T14:35:45.123Z");
            DateTimeIndex Index      = new DateTimeIndex();

            //Act
            IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(FhirString, Index);

            //Assert
            Assert.AreEqual(new DateTimeOffset(1974, 12, 25, 14, 35, 45, 123, new TimeSpan(00, 00, 00)), Index.DateTimeOffset);
        }
コード例 #9
0
        public void Test_FhirString_DateTimeIndexSetter_Date_GoodFormat()
        {
            //Arrange
            var           FhirString = new FhirString("1974-12-25");
            DateTimeIndex Index      = new DateTimeIndex();

            //Act
            IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(FhirString, Index);

            //Assert
            Assert.AreEqual(new DateTimeOffset(1974, 12, 25, 00, 00, 00, TimeZoneInfo.Local.GetUtcOffset(DateTime.Now)), Index.DateTimeOffset);
        }
コード例 #10
0
        public void Test_FhirDateTime_DateTimeIndexSetter_BadFormat_NoSecs()
        {
            //Arrange
            var           FhirDateTime = new FhirDateTime("1974-12-25T14:35-05:00");
            DateTimeIndex Index        = new DateTimeIndex();

            //Act
            ActualValueDelegate <DateTimeIndex> testDelegate = () => IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(FhirDateTime, Index) as DateTimeIndex;

            //Assert
            Assert.That(testDelegate, Throws.TypeOf <FormatException>());
        }
コード例 #11
0
        public void Test_FhirString_DateTimeIndexSetter_BadFormat_NoSecs()
        {
            //Arrange
            var           FhirString = new FhirString("1974-12-25T14:35-05:00");
            DateTimeIndex DateIndex  = new DateTimeIndex();


            //Act
            DateIndex = IndexSetterFactory.Create(typeof(DateTimeIndex)).Set(FhirString, DateIndex) as DateTimeIndex;

            //Assert
            Assert.IsNull(DateIndex);
        }
コード例 #12
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_FhirDateOfYearMonthToIndex()
        {
            //Arrange
            var            FhirDate     = new Date("1974-02");
            DateTimeOffset ExpectedLow  = new DateTimeOffset(1974, 02, 01, 00, 00, 00, 0, new TimeSpan(TimeZoneTestRunningWithin, 0, 0)).ToUniversalTime();
            DateTimeOffset ExpectedHigh = new DateTimeOffset(1974, 02, 28, 23, 59, 59, 999, new TimeSpan(TimeZoneTestRunningWithin, 0, 0)).ToUniversalTime();

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(FhirDate);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #13
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_FhirDateTimeOfYearMonthDayHrMinSecToIndex()
        {
            //Arrange
            var            FhirDate     = new FhirDateTime("1974-02-01T12:38:10+10:00");
            DateTimeOffset ExpectedLow  = new DateTimeOffset(1974, 02, 01, 12, 38, 10, 0, new TimeSpan(10, 0, 0)).ToUniversalTime();
            DateTimeOffset ExpectedHigh = new DateTimeOffset(1974, 02, 01, 12, 38, 10, 999, new TimeSpan(10, 0, 0)).ToUniversalTime();

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(FhirDate);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #14
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_InstantOfYearMonthDayHrMinSecTwoMiliSecToIndex()
        {
            //Arrange
            var FhirDate = new Instant(new DateTimeOffset(1974, 02, 01, 12, 38, 10, 22, new TimeSpan(10, 0, 0)));

            DateTimeOffset ExpectedLow  = new DateTimeOffset(1974, 02, 01, 12, 38, 10, 22, new TimeSpan(10, 0, 0)).ToUniversalTime();
            DateTimeOffset ExpectedHigh = new DateTimeOffset(1974, 02, 01, 12, 38, 10, 23, new TimeSpan(10, 0, 0)).AddTicks(-1).ToUniversalTime();

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(FhirDate);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #15
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_PeriodNoStartOrEndOnlyToIndex()
        {
            //Arrange
            var Period = new Period();

            DateTimeOffset?ExpectedLow  = null;
            DateTimeOffset?ExpectedHigh = null;

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(Period);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #16
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_PeriodStartAndEndToIndex()
        {
            //Arrange
            var Period = new Period(new FhirDateTime("1974-02-01T12:38:10+10:00"), new FhirDateTime("1974-02-01T12:38:20+10:00"));

            DateTimeOffset?ExpectedLow  = new DateTimeOffset(1974, 02, 01, 12, 38, 10, new TimeSpan(10, 0, 0)).ToUniversalTime();
            DateTimeOffset?ExpectedHigh = new DateTimeOffset(1974, 02, 01, 12, 38, 20, new TimeSpan(10, 0, 0)).ToUniversalTime();

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(Period);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
コード例 #17
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_FhirDateOfYearMonthDayToIndex()
        {
            //Arrange
            var FhirDate      = new Date("1974-02-01");
            var LocalTimeZone = DateTimeOffset.Now.Offset;

            DateTimeOffset ExpectedLow  = new DateTimeOffset(1974, 02, 01, 00, 00, 00, 0, LocalTimeZone).ToUniversalTime();
            DateTimeOffset ExpectedHigh = new DateTimeOffset(1974, 02, 01, 23, 59, 59, 999, LocalTimeZone).ToUniversalTime();

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(FhirDate);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low, "ExpectedLow");
            Assert.AreEqual(ExpectedHigh, Result.High, "ExpectedHigh");
        }
コード例 #18
0
        public void AllReturnsIndexesInDescendingOrder()
        {
            // Arrange
            IndexService service = new IndexService(_unitOfWorkFactory, _mapper);
            DateTimeIndex dateTimeIndex1 = new DateTimeIndex { StartDate = DateTime.Now.Subtract(TimeSpan.FromDays(2)) };
            DateTimeIndex dateTimeIndex2 = new DateTimeIndex { StartDate = DateTime.Now };
            List<DateTimeIndex> indices = new List<DateTimeIndex> { dateTimeIndex1, dateTimeIndex2 };
            DateTimeIndexViewModel model1 = new DateTimeIndexViewModel {NumberOfPosts = 1};
            DateTimeIndexViewModel model2 = new DateTimeIndexViewModel { NumberOfPosts = 2 };
            _mapper.Stub(x => x.Map(dateTimeIndex1)).Return(model1);
            _mapper.Stub(x => x.Map(dateTimeIndex2)).Return(model2);
            _repository.Stub(x => x.All).Return(indices.AsQueryable());

            // Act
            IEnumerable<DateTimeIndexViewModel> models = service.All();

            // Assert
            Assert.That(models.First(), Is.EqualTo(model2));
            Assert.That(models.Last(), Is.EqualTo(model1));
        }
コード例 #19
0
ファイル: Test_DateTimeSupport.cs プロジェクト: eug48/Pyro
        public void Test_TimingToIndex_Test2()
        {
            //Arrange
            var Timing = new Timing();

            DateTimeOffset?ExpectedLow = new DateTimeOffset(1974, 12, 25, 10, 00, 00, new TimeSpan(-5, 00, 00)).ToUniversalTime();

            Timing.EventElement = new System.Collections.Generic.List <FhirDateTime>();
            var EventStart1 = new FhirDateTime(new DateTimeOffset(1974, 12, 26, 11, 00, 00, new TimeSpan(-5, 00, 00)));
            var EventStart2 = new FhirDateTime(ExpectedLow.Value);

            Timing.EventElement.Add(EventStart1);
            Timing.EventElement.Add(EventStart2);

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(Timing);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.IsNull(Result.High);
        }
コード例 #20
0
        private WitsmlLogs GetSourceLogData(string startIndexValue, string endIndexValue)
        {
            var startIndex   = DateTimeIndex.FromString(startIndexValue);
            var endIndex     = DateTimeIndex.FromString(endIndexValue);
            var currentIndex = DateTimeIndex.FromString(startIndexValue);

            var data = new List <WitsmlData>();

            while (currentIndex <= endIndex)
            {
                data.Add(new WitsmlData {
                    Data = $"{currentIndex.GetValueAsString()},1,1"
                });
                currentIndex = new DateTimeIndex(currentIndex.Value.AddMinutes(1));
            }

            if (data.Any())
            {
                return(new WitsmlLogs
                {
                    Logs = new WitsmlLog
                    {
                        StartDateTimeIndex = startIndex.GetValueAsString(),
                        EndDateTimeIndex = endIndex.GetValueAsString(),
                        IndexType = WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME,
                        LogData = new WitsmlLogData
                        {
                            MnemonicList = string.Join(",", SourceMnemonics[WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME]),
                            UnitList = "datetime,m,m",
                            Data = data
                        }
                    }.AsSingletonList()
                });
            }

            return(new WitsmlLogs());
        }