コード例 #1
0
        public async Task GetAllTimeCards_ShouldAddEventsToCreatedAttendances_WhenUpdatedWithEndOfWork()
        {
            var userId     = Guid.NewGuid();
            var timeCardId = Guid.NewGuid();

            var card = new TimeCard {
                Id = timeCardId, UserId = userId,
            };

            TheSession.Store(card);

            var date1  = DateTime.Now;
            var start1 = new GettingWorkStarted(attendanceId1, userId, date1);
            var end1   = new EndOfWork(attendanceId2, userId, date1.AddHours(1));
            var start2 = new GettingWorkStarted(attendanceId3, userId, date1.AddHours(2));
            var end2   = new EndOfWork(attendanceId4, userId, date1.AddHours(3));

            TheSession.Events.Append(timeCardId, start1, end1, start2, end2);
            TheSession.SaveChanges();

            var repo      = new TimeCardsRepository(TheStore);
            var timeCards = await repo.GetAllTimeCards(userId, default);

            timeCards.Should().HaveCount(1);
        }
コード例 #2
0
        public async Task UpdateTimeCard_ShouldAddEventsToCreatedAttendances_WhenUpdatedWithEndOfWork()
        {
            var userId = Guid.NewGuid();

            var repo = new TimeCardsRepository(TheStore);

            var startDate = DateTime.Now;
            var start     = new GettingWorkStarted(attendanceId1, userId, startDate);
            var id        = await repo.CreateTimeCard(userId, start);

            var endDate = startDate.AddHours(2);

            var end = new EndOfWork(attendanceId2, userId, endDate);
            await repo.UpdateTimeCard(id, end);

            var timeCard = await repo.GetTimeCard(id);

            timeCard.WorkAttendances.Should().HaveCount(2);
        }