Ejemplo n.º 1
0
        public void produces_the_correct_results_given_a_non_empty_set(
            AppointmentCreated createdEvent,
            List <DomainEvent> events,
            Appointment expectedState)
        {
            var sut = new Appointment(createdEvent);

            sut.ReplayEvents(events);
            sut.Should().BeEquivalentTo(expectedState, c => c.Excluding(p => p.PendingEvents));
        }
Ejemplo n.º 2
0
 public Appointment(AppointmentCreated @event)
 {
     Id    = @event.AppointmentId;
     Pet   = @event.Data.Pet;
     Owner = @event.Data.Owner;
     AttendingVeterinarianId = @event.Data.AttendingVeterinarianId;
     ReasonForVisit          = @event.Data.ReasonForVisit;
     ScheduledOn             = @event.Data.ScheduledOn;
     State = @event.Data.State;
 }
Ejemplo n.º 3
0
        public async Task Handle(AppointmentCreated message)
        {
            var obj = this.ParseMessage(message);

            var notification = new Notification
            {
                Ods    = message.Destination,
                System = message.System,
                // need the patient NHS
                NhsNumber   = obj.Participant.SingleOrDefault(x => x.Actor.Reference.Contains("Patient"))?.Actor?.Identifier?.Value,
                DateCreated = DateTime.UtcNow,
                Type        = obj.TypeName,
                Summary     = $"Appointment {obj.Status}.",
                Details     = $"{obj.Description}",
                Json        = this.ToString()
            };

            await this.Notifications.AddOrUpdate(notification);

            await this.Hub.Clients.Group(message.Destination?.ToLowerInvariant()).SendAsync("notification", notification);
        }
Ejemplo n.º 4
0
        public void TestSaveAppointment()
        {
            var item = new Appointment()
            {
                Start     = DateTimeOffset.UtcNow,
                End       = DateTimeOffset.Now,
                Attendees = new List <Person>()
                {
                    new Person()
                    {
                        Email = "*****@*****.**",
                        Name  = "Jeff Jin"
                    },
                    new Person()
                    {
                        Email = "*****@*****.**",
                        Name  = "Inyu Jin"
                    }
                },
                Body      = "appointment body",
                Organizer = "Jeff",
                Subject   = "Test Subject"
            };
            var evt = new AppointmentCreated(item);

            Func <ReadModelContext> contextFactory        = () => new ReadModelContext();
            IReadModelStorage <AppointmentReadModel> repo = new SqlReadModelStorage(contextFactory);

            var handler = new AppointmentEventHandler(repo);

            handler.Handle(evt);

            var task = repo.GetAll(0, 1);

            task.Wait();

            var model = task.Result.SingleOrDefault();

            Assert.AreEqual(model.Start, item.Start);
        }