示例#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
        static void Main(string[] args)
        {
            Programmer prog     = new Programmer("Elena", "Programmer", 20, "Distance", "FRE");
            Engineer   engineer = new Engineer("Ivan", "Programmer", 21, "Evening", 1);
            Tester     tester   = new Tester("Vlad", "Programmer", 20, "Magistracy", "kafedra");

            prog.Uni();
            prog.DisplayInfo();
            prog.Info();

            engineer.Uni();
            engineer.DisplayInfo();
            engineer.Info();

            tester.Uni();
            tester.DisplayInfo();
            tester.Info();

            Console.WriteLine("\nSorting\n");

            Engineer[] mas = new Engineer[3];

            mas[0] = new Engineer("Elena", "Programmer", 20, "Belarus", 1);
            mas[1] = new Engineer("Ivan", "Ingenior", 21, "Belarus", 3);
            mas[2] = new Engineer("Vlad", "Programmer", 20, "Belarus", 2);

            Array.Sort(mas);

            foreach (Engineer x in mas)
            {
                x.DisplayInfo();
                Console.WriteLine();
            }

            WelcomeMessage message = Greeting;

            message += DisplayWinner;
            message(engineer.ReturnSpecialty(), engineer.ReturnName());

            message -= DisplayWinner;
            message(engineer.ReturnSpecialty(), engineer.ReturnName());

            message -= Greeting;
            message?.Invoke(engineer.ReturnSpecialty(), engineer.ReturnName());

            EndOfWork handler = delegate(string name)
            {
                Console.WriteLine($"\nBye, {name}");
            };

            handler(tester.ReturnName());

            tester.EndOfCareer += (object sender, EventArgs eventArgs) => Console.WriteLine($"\nYou've finished your studies, {tester.ReturnSpecialty()} {tester.ReturnName()}");
            tester.Training();

            tester.Show();
            Console.ReadLine();
        }
示例#3
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);
        }
示例#4
0
 public void Apply(EndOfWork end)
 {
     End = end.Timestamp;
 }