예제 #1
0
        public void GetNotifications_ContainsResult()
        {
            // Arrange
            new NotificationRepository(context).Save(new Notification()
            {
                NotificationId   = 999999,
                NotificationType = new NotificationTypeRepository(context).FindById(1),
                Contents         = "TEST",
                Status           = new StatusService(context).FindStatusByStatusId(1),
                CreatedFor       = new UserService(context).FindUserByEmail("*****@*****.**"),
                CreatedDateTime  = DateTime.Now,
            });
            var expected   = "TEST";
            var controller = new NotificationApiController
            {
                Request         = new HttpRequestMessage(),
                Configuration   = new HttpConfiguration(),
                CurrentUserName = "******"
            };

            // Act
            IHttpActionResult actionResult = controller.GetCurrentUser();
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <NotificationViewModel> >;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsTrue(contentResult.Content.Select(x => x.Contents).Contains(expected));
        }
예제 #2
0
        public void GetNotifications_NotFound()
        {
            // Arrange
            var controller = new NotificationApiController
            {
                Request         = new HttpRequestMessage(),
                Configuration   = new HttpConfiguration(),
                CurrentUserName = "******"
            };

            // Act
            IHttpActionResult actionResult = controller.GetCurrentUser();

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }