コード例 #1
0
            public void MergeIntervals_Normal_2Intervals(
                [Values(true, false)] bool reverse)
            {
                var intNow = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(0), EndTS = DateTime.Today.AddDays(1), RegistrationDate = DateTime.Today.AddDays(0)
                };
                var intPrv = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(-4), EndTS = DateTime.Today.AddDays(0), RegistrationDate = DateTime.Today.AddDays(-4)
                };

                var res = RegisteredInterval.MergeIntervals <RegisteredIntervalStub>(CreateArray(reverse, intNow, intPrv));

                Assert.AreEqual(intPrv, res.First());
                Assert.AreEqual(intNow, res.Last());
            }
コード例 #2
0
            public void MergeIntervals_2_ClosedIdenticalIntervals_LatestRegistrationDateWins(
                [Values(true, false)] bool reverse)
            {
                var intNow = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(0), EndTS = DateTime.Today.AddDays(5), RegistrationDate = DateTime.Today.AddDays(0)
                };
                var intPrv = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(0), EndTS = DateTime.Today.AddDays(5), RegistrationDate = DateTime.Today.AddDays(-4)
                };

                var res = RegisteredInterval.MergeIntervals <RegisteredIntervalStub>(CreateArray(reverse, intNow, intPrv));

                Assert.AreEqual(1, res.Length);
                Assert.AreEqual(intNow, res.First());
            }
コード例 #3
0
            public void MergeIntervals_2OpenStartAndEnd_OnlyLatestInterval(
                [Values(true, false)] bool reverse)
            {
                var intNow = new RegisteredIntervalStub()
                {
                    StartTS = null, EndTS = null, RegistrationDate = DateTime.Today.AddDays(0)
                };
                var intPrv = new RegisteredIntervalStub()
                {
                    StartTS = null, EndTS = null, RegistrationDate = DateTime.Today.AddDays(-4)
                };

                var res = RegisteredInterval.MergeIntervals <RegisteredIntervalStub>(CreateArray(reverse, intNow, intPrv));

                Assert.AreEqual(1, res.Length);
                Assert.AreEqual(intNow, res.First());
            }
コード例 #4
0
            public void MergeIntervals_2_ClosedStart_OpenEnd_1PastAnd1Current(
                [Values(true, false)] bool reverse)
            {
                var intNow = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(0), EndTS = null, RegistrationDate = DateTime.Today.AddDays(0)
                };
                var intPrv = new RegisteredIntervalStub()
                {
                    StartTS = DateTime.Today.AddDays(-5), EndTS = null, RegistrationDate = DateTime.Today.AddDays(-4)
                };

                var res = RegisteredInterval.MergeIntervals <RegisteredIntervalStub>(CreateArray(reverse, intNow, intPrv));

                Assert.AreEqual(2, res.Length);
                Assert.AreEqual(intPrv, res.First());
                Assert.AreEqual(intNow, res.Last());
                Assert.AreEqual(intNow.StartTS.Value, intPrv.EndTS.Value);
            }