protected override IDatabaseTimeEntry CreateCleanWithPositiveIdFrom(IDatabaseTimeEntry entity)
            {
                var te = new Ultrawave.Models.TimeEntry(entity);

                te.Id = 1;
                return(TimeEntry.Clean(te));
            }
        public void TimeEntryWhichHasStopTimeSetToAnythingElseThanNullCannotHaveRivals(DateTimeOffset stop)
        {
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = stop
            });

            var canHaveRival = resolver.CanHaveRival(a);

            canHaveRival.Should().BeFalse();
        }
        public void TimeEntryWhichHasStopTimeSetToNullCanHaveRivals()
        {
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null
            });

            var canHaveRival = resolver.CanHaveRival(a);

            canHaveRival.Should().BeTrue();
        }
        public void TwoTimeEntriesAreNotRivalsIfTheLatterOneHasTheStopTimeNotSetToNull(DateTimeOffset b)
        {
            var x = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null
            });
            var y = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 2, Stop = b
            });
            var areRivals = resolver.AreRivals(x).Compile()(y);

            areRivals.Should().BeFalse();
        }
Exemplo n.º 5
0
        public void TheStoppedEntityMustHaveTheStopTimeEqualToTheStartTimeOfTheNextEntryInTheDatabase()
        {
            var a = TimeEntry.Clean(new MockTimeEntry {
                Id = 1, Duration = null, At = arbitraryTime.AddDays(10), Start = arbitraryTime.AddDays(12)
            });
            var b = TimeEntry.Clean(new MockTimeEntry {
                Id = 2, Duration = null, At = arbitraryTime.AddDays(11), Start = arbitraryTime.AddDays(13)
            });

            var(fixedA, _) = resolver.FixRivals(a, b, timeEntries);

            fixedA.Duration.Should().Be((long)TimeSpan.FromDays(3).TotalSeconds);
        }
        public void TwoTimeEntriesAreRivalsIfBothOfThemHaveTheStopTimeSetToNull()
        {
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null
            });
            var b = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 2, Stop = null
            });

            var areRivals = resolver.AreRivals(a).Compile()(b);

            areRivals.Should().BeTrue();
        }
        public void TheStoppedEntityMustHaveTheStopTimeEqualToTheStartTimeOfTheNextEntryInTheDatabase()
        {
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null, At = arbitraryTime.AddDays(10), Start = arbitraryTime.AddDays(12)
            });
            var b = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 2, Stop = null, At = arbitraryTime.AddDays(11), Start = arbitraryTime.AddDays(13)
            });

            var(fixedA, _) = resolver.FixRivals(a, b, timeEntries);

            fixedA.Stop.Should().Be(arbitraryTime.AddDays(15));
        }
Exemplo n.º 8
0
        public void TheStoppedTimeEntryMustBeMarkedAsSyncNeededAndTheStatusOfTheOtherOneShouldNotChange()
        {
            var a = TimeEntry.Clean(new MockTimeEntry {
                Id = 1, Duration = null, At = arbitraryTime.AddDays(10)
            });
            var b = TimeEntry.Clean(new MockTimeEntry {
                Id = 2, Duration = null, At = arbitraryTime.AddDays(11)
            });

            var(fixedA, fixedB) = resolver.FixRivals(a, b, timeEntries);

            fixedA.SyncStatus.Should().Be(SyncStatus.SyncNeeded);
            fixedB.SyncStatus.Should().Be(SyncStatus.InSync);
        }
        public void TheStoppedEntityMustHaveTheStopTimeEqualToTheCurrentDateTimeOfTheTimeServiceWhenThereIsNoNextEntryInTheDatabase()
        {
            var now = arbitraryTime.AddDays(25);

            timeService.CurrentDateTime.Returns(now);
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null, At = arbitraryTime.AddDays(21), Start = arbitraryTime.AddDays(20)
            });
            var b = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 2, Stop = null, At = arbitraryTime.AddDays(22), Start = arbitraryTime.AddDays(21)
            });

            var(fixedA, _) = resolver.FixRivals(a, b, timeEntries);

            fixedA.Stop.Should().Be(now);
        }
        public void TheTimeEntryWhichHasBeenEditedTheLastWillBeRunningAndTheOtherWillBeStoppedAfterResolution(DateTimeOffset firstAt, DateTimeOffset secondAt)
        {
            (DateTimeOffset earlier, DateTimeOffset later) =
                firstAt < secondAt ? (firstAt, secondAt) : (secondAt, firstAt);
            var a = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 1, Stop = null, At = earlier
            });
            var b = TimeEntry.Clean(new Ultrawave.Models.TimeEntry {
                Id = 2, Stop = null, At = later
            });

            var(fixedEntityA, fixedRivalB) = resolver.FixRivals(a, b, timeEntries);
            var(fixedEntityB, fixedRivalA) = resolver.FixRivals(b, a, timeEntries);

            fixedEntityA.Stop.Should().NotBeNull();
            fixedRivalA.Stop.Should().NotBeNull();
            fixedRivalB.Stop.Should().BeNull();
            fixedEntityB.Stop.Should().BeNull();
        }
Exemplo n.º 11
0
        private void safeSetCurrentlyRunningTimeEntry(ITimeEntry timeEntry)
        {
            var next = timeEntry == null ? null : TimeEntry.Clean(timeEntry);

            currentTimeEntrySubject.OnNext(next);
        }
Exemplo n.º 12
0
 protected override IDatabaseTimeEntry ConvertToDatabaseEntity(ITimeEntry entity)
 => TimeEntry.Clean(entity);