Пример #1
0
        public async Task validate_new_actor_has_no_participations()
        {
            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();
            ParticipantActor        target = await CreateParticipantActor(ActorId.CreateRandom());

            var participations = await target.GetMonthParticipations(1, 2017);

            Assert.IsFalse(participations.Activities.Any());
            Assert.IsFalse(participations.Events.Any());
        }
Пример #2
0
        public async Task validate_annual_total_on_events_and_activities()
        {
            MockServiceProxyFactory serviceProxyFactory = new MockServiceProxyFactory();
            ParticipantActor        target = await CreateParticipantActor(ActorId.CreateRandom());

            var currentDate = DateTimeOffset.UtcNow;

            var current = await target.StateManager.GetStateAsync <Participations>(ParticipationsKeyName);

            int monthChanger = -1;

            if (currentDate.Month == 1)
            {
                monthChanger = 1;
            }

            var record = current.Records.FirstOrDefault();

            record.Events.Add(new ParticipantEvent()
            {
                Id = Guid.NewGuid().ToString(), Points = 1, Date = currentDate.AddMonths(monthChanger)
            });
            record.Events.Add(new ParticipantEvent()
            {
                Id = Guid.NewGuid().ToString(), Points = 1, Date = currentDate
            });
            record.Activities.Add(new ParticipantActivity()
            {
                Points = 1, Date = currentDate
            });

            await target.StateManager.SetStateAsync(ParticipationsKeyName, current);

            var participations = await target.GetMonthParticipations(currentDate.Month, currentDate.Year);

            Assert.AreEqual(3, participations.AnnualTotalPoints);
        }