Ejemplo n.º 1
0
        public void AddRegisteredUserToEvent_Integration_CallWebAPI_RegisteredUserAdded_NotFail_Test()
        {
            int registeredUserId = 0;
            int eventDefinitionId = 0;
            int expected = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                registeredUserId = context.RegisteredUsers.First().RegisteredUserId;
                var eventDefinition = context.EventDefinitions.Include("RegisteredUsers")
                    .Where(e => !e.RegisteredUsers.Any(r => r.RegisteredUserId == registeredUserId)).First();
                eventDefinitionId = eventDefinition.EventDefinitionId;
                expected = eventDefinition.RegisteredUsers.Count() + 1;
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(registeredUserId));
            IAsyncResult ar = service.RegisteredUserService.AddRegisteredUserToEventAsync(registeredUserId, eventDefinitionId, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    var eventDefinition = context.EventDefinitions.Include("RegisteredUsers").First(e => e.EventDefinitionId == eventDefinitionId);
                    int actual = eventDefinition.RegisteredUsers.Count();
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void GetEventDefinitionById_CallWebAPI_GetDefinition_NotFail_Test()
        {
            EventDefinition expected;
            var             manualResetEvent = new ManualResetEvent(false);
            var             exceptionResult  = default(Exception);

            using (var context = new MyEventsContext())
            {
                expected = context.EventDefinitions.First();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(expected.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(expected.EventDefinitionId, (Client.EventDefinition actual) =>
            {
                try
                {
                    Assert.AreEqual(expected.Name, actual.Name);
                    Assert.AreEqual(expected.OrganizerId, actual.OrganizerId);
                    Assert.AreEqual(expected.EventDefinitionId, actual.EventDefinitionId);
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 3
0
        public void DeleteComment_Integration_CallWebAPI_Deleted_NotFail_Test()
        {
            int expected         = 0;
            int sessionId        = 0;
            int organizerId      = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            using (var context = new MyEventsContext())
            {
                sessionId   = context.Comments.First().SessionId;
                expected    = context.Comments.Count(q => q.SessionId == sessionId) - 1;
                organizerId = context.Sessions.Include("EventDefinition")
                              .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.CommentService.GetAllCommentsAsync(sessionId, (IList <Client.Comment> comments) =>
            {
                IAsyncResult arUpdate = service.CommentService.DeleteCommentAsync(comments.First().CommentId, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        int actual = context.Comments.Count(q => q.SessionId == sessionId);
                        TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                    }
                });
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 4
0
        public void AddRoomPoints_CallWebAPI_NotFail_Test()
        {
            var context = new MyEventsContext();
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            var eventDefinition = context.EventDefinitions.First();
            List<Client.RoomPoint> points = new List<Client.RoomPoint>()
            {
                new Client.RoomPoint() { EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 0, PointY = 0 },
                new Client.RoomPoint() { EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 1, PointY = 2 },
                new Client.RoomPoint() { EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 3, PointY = 4 },
            };

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult asynResult = service.RoomPointService.AddRoomPointsAsync(points, (HttpStatusCode code) =>
            {
                using (var contextAfter = new MyEventsContext())
                {
                    var actual = contextAfter.RoomPoints.Where(q => q.EventDefinitionId == eventDefinition.EventDefinitionId).Count();
                    TestHelper.ValidateResult(points.Count(), actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 5
0
        public void PutSessionPeriod_Integration_CallWebAPI_Updated_NotFail_Test()
        {
            Session session;
            string  startTime        = DateTime.Now.ToString();
            int     duration         = 60;
            var     manualResetEvent = new ManualResetEvent(false);
            var     exceptionResult  = default(Exception);

            using (var context = new MyEventsContext())
            {
                session = context.Sessions.Include("EventDefinition").First();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.UpdateSessionPeriodAsync(session.SessionId, startTime, duration, (HttpStatusCode statusCode) =>
            {
                using (var context = new MyEventsContext())
                {
                    var actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                    TestHelper.ValidateResult(duration, actual.Duration, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void PostRegisteredUserScore_Integration_CallWebAPI_RegisteredUserAdded_NotFail_Test()
        {
            int registeredUserId = 0;
            int sessionId        = 0;
            int expected         = 4;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                registeredUserId = context.SessionRegisteredUsers.First().RegisteredUserId;
                sessionId        = context.SessionRegisteredUsers.First().SessionId;
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(registeredUserId));
            IAsyncResult ar = service.RegisteredUserService.AddRegisteredUserScoreAsync(registeredUserId, sessionId, expected, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    double actual = context.SessionRegisteredUsers.Where(q => q.RegisteredUserId == registeredUserId && q.SessionId == sessionId).First().Score;
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });


            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 7
0
        public void DeleteSession_Integration_CallWebAPI_Deleted_NotFail_Test()
        {
            Session session;
            int     expected         = 0;
            var     manualResetEvent = new ManualResetEvent(false);
            var     exceptionResult  = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                session  = context.Sessions.Include("EventDefinition").First();
                expected = context.Sessions.Count() - 1;
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.DeleteSessionAsync(session.SessionId, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    Session actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                    TestHelper.ValidateResult(null, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 8
0
        public void DeleteComment_Integration_CallWebAPI_Deleted_NotFail_Test()
        {
            int expected = 0;
            int sessionId = 0;
            int organizerId = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            using (var context = new MyEventsContext())
            {
                sessionId = context.Comments.First().SessionId;
                expected = context.Comments.Count(q => q.SessionId == sessionId) - 1;
                organizerId = context.Sessions.Include("EventDefinition")
                    .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.CommentService.GetAllCommentsAsync(sessionId, (IList<Client.Comment> comments) =>
            {
                IAsyncResult arUpdate = service.CommentService.DeleteCommentAsync(comments.First().CommentId, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        int actual = context.Comments.Count(q => q.SessionId == sessionId);
                        TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                    }
                });

            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 9
0
        public void DeleteEventDefinition_CallWebAPI_EventDeleted_NotFail_Test()
        {
            EventDefinition eventDef;
            int organizerId = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                organizerId = context.RegisteredUsers.First().RegisteredUserId;

                // Create event to delete
                eventDef = new EventDefinition();
                eventDef.OrganizerId = organizerId;
                eventDef.Name = Guid.NewGuid().ToString();
                eventDef.Description = Guid.NewGuid().ToString();
                eventDef.Address = Guid.NewGuid().ToString();
                eventDef.City = Guid.NewGuid().ToString();
                eventDef.Tags = Guid.NewGuid().ToString();
                eventDef.TwitterAccount = Guid.NewGuid().ToString();
                eventDef.RoomNumber = 1;
                eventDef.Date = System.DateTime.Now;
                eventDef.StartTime = System.DateTime.Now;
                eventDef.EndTime = System.DateTime.Now.AddDays(1);
                eventDef.TimeZoneOffset = 2;
                eventDef.Likes = 0;
                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                eventDef.Logo = encoding.GetBytes("sample");
                context.EventDefinitions.Add(eventDef);
                context.SaveChanges();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(eventDef.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(eventDef.EventDefinitionId, (Client.EventDefinition getEvent) =>
            {
                IAsyncResult arUpdate = service.EventDefinitionService.DeleteEventDefinitionAsync(getEvent.EventDefinitionId, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        var actual = context.EventDefinitions.FirstOrDefault(q => q.EventDefinitionId == eventDef.EventDefinitionId);
                        TestHelper.ValidateResult(null, actual, manualResetEvent, ref exceptionResult);
                    }
                });

            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void DeleteEventDefinition_CallWebAPI_EventDeleted_NotFail_Test()
        {
            EventDefinition eventDef;
            int             organizerId      = 0;
            var             manualResetEvent = new ManualResetEvent(false);
            var             exceptionResult  = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                organizerId = context.RegisteredUsers.First().RegisteredUserId;

                // Create event to delete
                eventDef                = new EventDefinition();
                eventDef.OrganizerId    = organizerId;
                eventDef.Name           = Guid.NewGuid().ToString();
                eventDef.Description    = Guid.NewGuid().ToString();
                eventDef.Address        = Guid.NewGuid().ToString();
                eventDef.City           = Guid.NewGuid().ToString();
                eventDef.Tags           = Guid.NewGuid().ToString();
                eventDef.TwitterAccount = Guid.NewGuid().ToString();
                eventDef.RoomNumber     = 1;
                eventDef.Date           = System.DateTime.Now;
                eventDef.StartTime      = System.DateTime.Now;
                eventDef.EndTime        = System.DateTime.Now.AddDays(1);
                eventDef.TimeZoneOffset = 2;
                eventDef.Likes          = 0;
                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                eventDef.Logo = encoding.GetBytes("sample");
                context.EventDefinitions.Add(eventDef);
                context.SaveChanges();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(eventDef.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(eventDef.EventDefinitionId, (Client.EventDefinition getEvent) =>
            {
                IAsyncResult arUpdate = service.EventDefinitionService.DeleteEventDefinitionAsync(getEvent.EventDefinitionId, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        var actual = context.EventDefinitions.FirstOrDefault(q => q.EventDefinitionId == eventDef.EventDefinitionId);
                        TestHelper.ValidateResult(null, actual, manualResetEvent, ref exceptionResult);
                    }
                });
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 11
0
        public void PutSession_Integration_CallWebAPI_Updated_NotFail_Test()
        {
            Session session;
            var     manualResetEvent = new ManualResetEvent(false);
            var     exceptionResult  = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                session = context.Sessions.Include("EventDefinition").First();
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.GetSessionAsync(session.SessionId, (Client.Session getSession) =>
            {
                Client.Session sessionToUpdate    = new Client.Session();
                sessionToUpdate.SessionId         = getSession.SessionId;
                sessionToUpdate.EventDefinitionId = getSession.EventDefinitionId;
                sessionToUpdate.Description       = getSession.Description;
                sessionToUpdate.Speaker           = getSession.Speaker;
                sessionToUpdate.Biography         = getSession.Biography;
                sessionToUpdate.TwitterAccount    = getSession.TwitterAccount;
                sessionToUpdate.StartTime         = getSession.StartTime;
                sessionToUpdate.Duration          = getSession.Duration;

                sessionToUpdate.Title = Guid.NewGuid().ToString();

                ar = service.SessionService.UpdateSessionAsync(sessionToUpdate, (HttpStatusCode statusCode) =>
                {
                    // Asserts
                    using (var context = new MyEventsContext())
                    {
                        Session actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                        TestHelper.ValidateResult(sessionToUpdate.Title, actual.Title, manualResetEvent, ref exceptionResult);
                    }
                });
            });


            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 12
0
        public void PostSession_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int             expected         = 0;
            var             manualResetEvent = new ManualResetEvent(false);
            var             exceptionResult  = default(Exception);
            EventDefinition eventDefinition;

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            string urlToTest = String.Format("{0}api/session/PostSession", urlPrefix);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                eventDefinition = context.EventDefinitions.Include("Sessions").FirstOrDefault();
                expected        = eventDefinition.Sessions.Count() + 1;
            }

            // Create object to add
            Client.Session session = new Client.Session();
            session.EventDefinitionId = eventDefinition.EventDefinitionId;
            session.Title             = Guid.NewGuid().ToString();
            session.Description       = Guid.NewGuid().ToString();
            session.Speaker           = Guid.NewGuid().ToString();
            session.Biography         = Guid.NewGuid().ToString();
            session.TwitterAccount    = Guid.NewGuid().ToString();
            session.StartTime         = DateTime.Now;
            session.Duration          = 60;
            session.TimeZoneOffset    = 2;

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.AddSessionAsync(session, (int sessionId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Sessions.Count(q => q.EventDefinitionId == eventDefinition.EventDefinitionId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });


            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 13
0
        public void PostComment_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int expected         = 0;
            int registeredUserId = 0;
            int sessionId        = 0;
            int organizerId      = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            using (var context = new MyEventsContext())
            {
                var firstComment = context.Comments.First();
                sessionId        = firstComment.SessionId;
                registeredUserId = firstComment.RegisteredUserId;
                expected         = context.Comments.Count(q => q.SessionId == sessionId && q.RegisteredUserId == registeredUserId) + 1;
                organizerId      = context.Sessions.Include("EventDefinition")
                                   .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }


            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            string urlToTest = String.Format("{0}api/session/PostComment", urlPrefix);


            // Create object to add
            Client.Comment comment = new Client.Comment();
            comment.SessionId        = sessionId;
            comment.RegisteredUserId = registeredUserId;
            comment.Text             = Guid.NewGuid().ToString();

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.CommentService.AddCommentAsync(comment, (int commentId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Comments.Count(q => q.SessionId == sessionId && q.RegisteredUserId == registeredUserId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 14
0
        public void PostMaterial_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int expected         = 0;
            int sessionId        = 0;
            int organizerId      = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            using (var context = new MyEventsContext())
            {
                sessionId   = context.Materials.First().SessionId;
                expected    = context.Materials.Count(q => q.SessionId == sessionId) + 1;
                organizerId = context.Sessions.Include("EventDefinition")
                              .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }


            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            // Create object to add
            Client.Material material = new Client.Material();
            material.SessionId   = sessionId;
            material.Name        = Guid.NewGuid().ToString();
            material.ContentType = "image/jpeg";

            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            material.Content = encoding.GetBytes("content");

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.MaterialService.AddMaterialAsync(material, (int materialId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Materials.Count(q => q.SessionId == sessionId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 15
0
        public void AddRoomPoints_CallWebAPI_NotFail_Test()
        {
            var context          = new MyEventsContext();
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            var eventDefinition            = context.EventDefinitions.First();
            List <Client.RoomPoint> points = new List <Client.RoomPoint>()
            {
                new Client.RoomPoint()
                {
                    EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 0, PointY = 0
                },
                new Client.RoomPoint()
                {
                    EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 1, PointY = 2
                },
                new Client.RoomPoint()
                {
                    EventDefinitionId = eventDefinition.EventDefinitionId, PointX = 3, PointY = 4
                },
            };

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult asynResult = service.RoomPointService.AddRoomPointsAsync(points, (HttpStatusCode code) =>
            {
                using (var contextAfter = new MyEventsContext())
                {
                    var actual = contextAfter.RoomPoints.Where(q => q.EventDefinitionId == eventDefinition.EventDefinitionId).Count();
                    TestHelper.ValidateResult(points.Count(), actual, manualResetEvent, ref exceptionResult);
                }
            });


            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 16
0
        public void UpdateRoomImage_CallWebAPI_NotFail_Test()
        {
            var context          = new MyEventsContext();
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            var eventDefinition = context.EventDefinitions.First(q => q.MapImage == null);

            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            var image = encoding.GetBytes("sample");

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult asynResult = service.RoomPointService.UpdateRoomImageAsync(eventDefinition.EventDefinitionId, image, (HttpStatusCode code) =>
            {
                try
                {
                    using (var contextAfter = new MyEventsContext())
                    {
                        var actual = contextAfter.EventDefinitions.Where(q => q.EventDefinitionId == eventDefinition.EventDefinitionId).FirstOrDefault().MapImage;
                        Assert.IsNotNull(actual);
                    }
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });


            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void DeleteRegisteredUserFromEvent_Integration_CallWebAPI_RegisteredUserIdeleted_NotFail_Test()
        {
            int registeredUserId  = 0;
            int eventDefinitionId = 0;
            int expected          = 0;
            var manualResetEvent  = new ManualResetEvent(false);
            var exceptionResult   = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                var eventDefinition = context.EventDefinitions.Include("RegisteredUsers")
                                      .Where(e => e.RegisteredUsers.Any()).First();

                registeredUserId  = eventDefinition.RegisteredUsers.First().RegisteredUserId;
                eventDefinitionId = eventDefinition.EventDefinitionId;
                expected          = eventDefinition.RegisteredUsers.Count() - 1;
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var    service   = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(registeredUserId));
            IAsyncResult ar = service.RegisteredUserService.DeleteRegisteredUserFromEventAsync(registeredUserId, eventDefinitionId, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    var eventDefinition = context.EventDefinitions.Include("RegisteredUsers").First(e => e.EventDefinitionId == eventDefinitionId);
                    int actual          = eventDefinition.RegisteredUsers.Count();
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void PutEventDefinition_CallWebAPI_EventUpdated_NotFail_Test()
        {
            EventDefinition expected;
            var             manualResetEvent = new ManualResetEvent(false);
            var             exceptionResult  = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                expected = context.EventDefinitions.First();
            }

            // Get Event To Update
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(expected.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(expected.EventDefinitionId, (Client.EventDefinition eventToUpdate) =>
            {
                eventToUpdate.Name            = Guid.NewGuid().ToString();
                eventToUpdate.RegisteredUsers = null;
                eventToUpdate.Organizer       = null;
                eventToUpdate.Sessions        = null;
                IAsyncResult arUpdate         = service.EventDefinitionService.UpdateEventDefinitionAsync(eventToUpdate, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        string actual = context.EventDefinitions.FirstOrDefault(q => q.EventDefinitionId == eventToUpdate.EventDefinitionId).Name;
                        TestHelper.ValidateResult(eventToUpdate.Name, actual, manualResetEvent, ref exceptionResult);
                    }
                });
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 19
0
        public void DeleteSession_Integration_CallWebAPI_Deleted_NotFail_Test()
        {
            Session session;
            int expected = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                session = context.Sessions.Include("EventDefinition").First();
                expected = context.Sessions.Count() - 1;
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.DeleteSessionAsync(session.SessionId, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    Session actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                    TestHelper.ValidateResult(null, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 20
0
        public void PutEventDefinition_CallWebAPI_EventUpdated_NotFail_Test()
        {
            EventDefinition expected;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                expected = context.EventDefinitions.First();
            }

            // Get Event To Update
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(expected.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(expected.EventDefinitionId, (Client.EventDefinition eventToUpdate) =>
            {
                eventToUpdate.Name = Guid.NewGuid().ToString();
                eventToUpdate.RegisteredUsers = null;
                eventToUpdate.Organizer = null;
                eventToUpdate.Sessions = null;
                IAsyncResult arUpdate = service.EventDefinitionService.UpdateEventDefinitionAsync(eventToUpdate, (HttpStatusCode statusCode) =>
                {
                    using (var context = new MyEventsContext())
                    {
                        string actual = context.EventDefinitions.FirstOrDefault(q => q.EventDefinitionId == eventToUpdate.EventDefinitionId).Name;
                        TestHelper.ValidateResult(eventToUpdate.Name, actual, manualResetEvent, ref exceptionResult);
                    }
                });

            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 21
0
        public void UpdateRoomImage_CallWebAPI_NotFail_Test()
        {
            var context = new MyEventsContext();
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            var eventDefinition = context.EventDefinitions.First(q => q.MapImage == null);
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            var image = encoding.GetBytes("sample");

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult asynResult = service.RoomPointService.UpdateRoomImageAsync(eventDefinition.EventDefinitionId, image, (HttpStatusCode code) =>
            {
                try
                {
                    using (var contextAfter = new MyEventsContext())
                    {
                        var actual = contextAfter.EventDefinitions.Where(q => q.EventDefinitionId == eventDefinition.EventDefinitionId).FirstOrDefault().MapImage;
                        Assert.IsNotNull(actual);
                    }
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 22
0
        public void PostEventDefinition_CallWebAPI_EventAdded_NotFail_Test()
        {
            int organizerId = 0;
            int expected = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            // Get values to test
            using (var context = new MyEventsContext())
            {
                organizerId = context.EventDefinitions.First().OrganizerId;
                expected = context.EventDefinitions.Count(q => q.OrganizerId == organizerId) + 1;
            }

            // Create object to add
            var eventDef = new Client.EventDefinition();
            eventDef.OrganizerId = organizerId;
            eventDef.Name = Guid.NewGuid().ToString();
            eventDef.Description = Guid.NewGuid().ToString();
            eventDef.Address = Guid.NewGuid().ToString();
            eventDef.City = Guid.NewGuid().ToString();
            eventDef.Tags = Guid.NewGuid().ToString();
            eventDef.TwitterAccount = Guid.NewGuid().ToString();
            eventDef.RoomNumber = 1;
            eventDef.Date = System.DateTime.Now;
            eventDef.StartTime = System.DateTime.Now;
            eventDef.EndTime = System.DateTime.Now.AddDays(1);
            eventDef.TimeZoneOffset = 2;
            eventDef.Latitude = 0;
            eventDef.Longitude = 0;
            eventDef.Likes = 0;
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            eventDef.Logo = encoding.GetBytes("sample");

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(eventDef.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.AddEventDefinitionAsync(eventDef, (int eventDefinitionId) =>
            {
                try
                {
                    // Asserts
                    using (var context = new MyEventsContext())
                    {
                        Assert.IsTrue(eventDefinitionId > 0);
                        int actual = context.EventDefinitions.Count(q => q.OrganizerId == organizerId);
                        Assert.AreEqual(expected, actual);
                    }
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 23
0
        public void PostRegisteredUserScore_Integration_CallWebAPI_RegisteredUserAdded_NotFail_Test()
        {
            int registeredUserId = 0;
            int sessionId = 0;
            int expected = 4;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                registeredUserId = context.SessionRegisteredUsers.First().RegisteredUserId;
                sessionId = context.SessionRegisteredUsers.First().SessionId;
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(registeredUserId));
            IAsyncResult ar = service.RegisteredUserService.AddRegisteredUserScoreAsync(registeredUserId, sessionId, expected, (HttpStatusCode statusCode) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    double actual = context.SessionRegisteredUsers.Where(q => q.RegisteredUserId == registeredUserId && q.SessionId == sessionId).First().Score;
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 24
0
        public void PutSession_Integration_CallWebAPI_Updated_NotFail_Test()
        {
            Session session;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                session = context.Sessions.Include("EventDefinition").First();
            }

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.GetSessionAsync(session.SessionId, (Client.Session getSession) =>
            {
                Client.Session sessionToUpdate = new Client.Session();
                sessionToUpdate.SessionId = getSession.SessionId;
                sessionToUpdate.EventDefinitionId = getSession.EventDefinitionId;
                sessionToUpdate.Description = getSession.Description;
                sessionToUpdate.Speaker = getSession.Speaker;
                sessionToUpdate.Biography = getSession.Biography;
                sessionToUpdate.TwitterAccount = getSession.TwitterAccount;
                sessionToUpdate.StartTime = getSession.StartTime;
                sessionToUpdate.Duration = getSession.Duration;

                sessionToUpdate.Title = Guid.NewGuid().ToString();

                ar = service.SessionService.UpdateSessionAsync(sessionToUpdate, (HttpStatusCode statusCode) =>
                {
                    // Asserts
                    using (var context = new MyEventsContext())
                    {
                        Session actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                        TestHelper.ValidateResult(sessionToUpdate.Title, actual.Title, manualResetEvent, ref exceptionResult);
                    }
                });

            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 25
0
        public void PostSession_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int expected = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);
            EventDefinition eventDefinition;

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            string urlToTest = String.Format("{0}api/session/PostSession", urlPrefix);

            // Get values to test
            using (var context = new MyEventsContext())
            {
                eventDefinition = context.EventDefinitions.Include("Sessions").FirstOrDefault();
                expected = eventDefinition.Sessions.Count() + 1;
            }

            // Create object to add
            Client.Session session = new Client.Session();
            session.EventDefinitionId = eventDefinition.EventDefinitionId;
            session.Title = Guid.NewGuid().ToString();
            session.Description = Guid.NewGuid().ToString();
            session.Speaker = Guid.NewGuid().ToString();
            session.Biography = Guid.NewGuid().ToString();
            session.TwitterAccount = Guid.NewGuid().ToString();
            session.StartTime = DateTime.Now;
            session.Duration = 60;
            session.TimeZoneOffset = 2;

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(eventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.AddSessionAsync(session, (int sessionId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Sessions.Count(q => q.EventDefinitionId == eventDefinition.EventDefinitionId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 26
0
        public void PutSessionPeriod_Integration_CallWebAPI_Updated_NotFail_Test()
        {
            Session session;
            string startTime = DateTime.Now.ToString();
            int duration = 60;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            using (var context = new MyEventsContext())
            {
                session = context.Sessions.Include("EventDefinition").First();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(session.EventDefinition.OrganizerId));
            IAsyncResult ar = service.SessionService.UpdateSessionPeriodAsync(session.SessionId, startTime, duration, (HttpStatusCode statusCode) =>
            {
                using (var context = new MyEventsContext())
                {
                    var actual = context.Sessions.FirstOrDefault(q => q.SessionId == session.SessionId);
                    TestHelper.ValidateResult(duration, actual.Duration, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
        public void PostEventDefinition_CallWebAPI_EventAdded_NotFail_Test()
        {
            int organizerId      = 0;
            int expected         = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult  = default(Exception);

            // Method to Test
            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            // Get values to test
            using (var context = new MyEventsContext())
            {
                organizerId = context.EventDefinitions.First().OrganizerId;
                expected    = context.EventDefinitions.Count(q => q.OrganizerId == organizerId) + 1;
            }

            // Create object to add
            var eventDef = new Client.EventDefinition();

            eventDef.OrganizerId    = organizerId;
            eventDef.Name           = Guid.NewGuid().ToString();
            eventDef.Description    = Guid.NewGuid().ToString();
            eventDef.Address        = Guid.NewGuid().ToString();
            eventDef.City           = Guid.NewGuid().ToString();
            eventDef.Tags           = Guid.NewGuid().ToString();
            eventDef.TwitterAccount = Guid.NewGuid().ToString();
            eventDef.RoomNumber     = 1;
            eventDef.Date           = System.DateTime.Now;
            eventDef.StartTime      = System.DateTime.Now;
            eventDef.EndTime        = System.DateTime.Now.AddDays(1);
            eventDef.TimeZoneOffset = 2;
            eventDef.Latitude       = 0;
            eventDef.Longitude      = 0;
            eventDef.Likes          = 0;
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            eventDef.Logo = encoding.GetBytes("sample");

            var service = new Client.MyEventsClient(urlPrefix);

            service.SetAccessToken(MyEventsToken.CreateToken(eventDef.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.AddEventDefinitionAsync(eventDef, (int eventDefinitionId) =>
            {
                try
                {
                    // Asserts
                    using (var context = new MyEventsContext())
                    {
                        Assert.IsTrue(eventDefinitionId > 0);
                        int actual = context.EventDefinitions.Count(q => q.OrganizerId == organizerId);
                        Assert.AreEqual(expected, actual);
                    }
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 28
0
        public void PostComment_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int expected = 0;
            int registeredUserId = 0;
            int sessionId = 0;
            int organizerId = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            using (var context = new MyEventsContext())
            {
                var firstComment = context.Comments.First();
                sessionId = firstComment.SessionId;
                registeredUserId = firstComment.RegisteredUserId;
                expected = context.Comments.Count(q => q.SessionId == sessionId && q.RegisteredUserId == registeredUserId) + 1;
                organizerId = context.Sessions.Include("EventDefinition")
                     .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            string urlToTest = String.Format("{0}api/session/PostComment", urlPrefix);

            // Create object to add
            Client.Comment comment = new Client.Comment();
            comment.SessionId = sessionId;
            comment.RegisteredUserId = registeredUserId;
            comment.Text = Guid.NewGuid().ToString();

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.CommentService.AddCommentAsync(comment, (int commentId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Comments.Count(q => q.SessionId == sessionId && q.RegisteredUserId == registeredUserId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 29
0
        public void PostMaterial_Integration_CallWebAPI_Added_NotFail_Test()
        {
            int expected = 0;
            int sessionId = 0;
            int organizerId = 0;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            using (var context = new MyEventsContext())
            {
                sessionId = context.Materials.First().SessionId;
                expected = context.Materials.Count(q => q.SessionId == sessionId) + 1;
                organizerId = context.Sessions.Include("EventDefinition")
                    .FirstOrDefault(q => q.SessionId == sessionId).EventDefinition.OrganizerId;
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();

            // Create object to add
            Client.Material material = new Client.Material();
            material.SessionId = sessionId;
            material.Name = Guid.NewGuid().ToString();
            material.ContentType = "image/jpeg";

            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            material.Content = encoding.GetBytes("content");

            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(organizerId));
            IAsyncResult ar = service.MaterialService.AddMaterialAsync(material, (int materialId) =>
            {
                // Asserts
                using (var context = new MyEventsContext())
                {
                    int actual = context.Materials.Count(q => q.SessionId == sessionId);
                    TestHelper.ValidateResult(expected, actual, manualResetEvent, ref exceptionResult);
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }
Ejemplo n.º 30
0
        public void GetEventDefinitionById_CallWebAPI_GetDefinition_NotFail_Test()
        {
            EventDefinition expected;
            var manualResetEvent = new ManualResetEvent(false);
            var exceptionResult = default(Exception);

            using (var context = new MyEventsContext())
            {
                expected = context.EventDefinitions.First();
            }

            string urlPrefix = testContextInstance.Properties[TestContext.AspNetDevelopmentServerPrefix + "webapiserver"].ToString();
            var service = new Client.MyEventsClient(urlPrefix);
            service.SetAccessToken(MyEventsToken.CreateToken(expected.OrganizerId));
            IAsyncResult ar = service.EventDefinitionService.GetEventDefinitionByIdAsync(expected.EventDefinitionId, (Client.EventDefinition actual) =>
            {
                try
                {
                    Assert.AreEqual(expected.Name, actual.Name);
                    Assert.AreEqual(expected.OrganizerId, actual.OrganizerId);
                    Assert.AreEqual(expected.EventDefinitionId, actual.EventDefinitionId);
                }
                catch (Exception ex)
                {
                    exceptionResult = ex;
                }
                finally
                {
                    manualResetEvent.Set();
                }
            });

            TestHelper.WaitAll(manualResetEvent, ref exceptionResult);
        }