Beispiel #1
0
        public void TestSaveAppointment()
        {
            var item = new AppointmentReadModel()
            {
                Start          = DateTimeOffset.UtcNow,
                End            = DateTimeOffset.Now,
                AttendeeNames  = "Jeff, Mike",
                Body           = "appointment body",
                Organizer      = "Jeff",
                Subject        = "Test Subject",
                TimeZoneOffset = 5
            };
            Func <ReadModelContext> contextFactory        = () => new ReadModelContext();
            IReadModelStorage <AppointmentReadModel> repo = new SqlReadModelStorage(contextFactory);

            repo.Save(item).Wait();

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

            task.Wait();

            var model = task.Result.SingleOrDefault();

            Assert.AreEqual(model.Start, item.Start);
        }
Beispiel #2
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);
        }