public void ReadNotification_Read_Redirect()
        {
            // Arrange
            var controller = new NotificationController()
            {
                Context = context
            };
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId   = notificationId,
                NotificationType = new NotificationTypeRepository(context).FindById(1),
                Contents         = "DSB-201801-001",
                Status           = new StatusService(context).FindStatusByStatusId(15),
                CreatedDateTime  = DateTime.Now
            });

            // Act
            var result = controller.Read(notificationId);

            // Assert
            Assert.AreEqual(15, notificationService.FindNotificationById(notificationId).Status.StatusId);
            result.AssertActionRedirect().ToAction("DisbursementDetails");
        }
Пример #2
0
        public void GetNewNotificationIdTest()
        {
            // Act
            var result = IdService.GetNewNotificationId(context);

            // Assert
            Assert.IsNotNull(result);
        }
        public void TestCleanup()
        {
            var usedNotificationId = IdService.GetNewNotificationId(context) - 1;

            if (notificationRepository.ExistsById(usedNotificationId))
            {
                notificationRepository.Delete(notificationRepository.FindById(usedNotificationId));
            }
        }
        public void ReadNotification_AlreadyRead()
        {
            // Arrange
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                Status          = new StatusService(context).FindStatusByStatusId(15),
                CreatedDateTime = DateTime.Now
            });

            // Act
            var result = notificationService.ReadNotification(notificationId);
        }
        public void FindNotificationById_DoesNotExist_ReturnNull()
        {
            // Arrange
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                CreatedDateTime = DateTime.Now
            });

            // Act
            var result = notificationService.FindNotificationById(0);

            // Assert
            Assert.IsNull(result);
        }
        public void FindNotificationById_Exists()
        {
            // Arrange
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                CreatedDateTime = DateTime.Now
            });

            // Act
            var result = notificationService.FindNotificationById(notificationId);

            // Assert
            Assert.AreEqual(notificationId, result.NotificationId);
        }
        public void FindUserByDepartment_NullInput()
        {
            // Arrange
            var notificationId = IdService.GetNewNotificationId(context);

            notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                CreatedDateTime = DateTime.Now
            });

            // Act
            var result = notificationService.FindNotificationsByUser(null);

            // Assert
            Assert.IsTrue(result.Count == 0);
        }
        public void FindNotificationsByUserTest()
        {
            //Arrange
            var notificationId = IdService.GetNewNotificationId(context);
            var notification   = notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                CreatedDateTime = DateTime.Now,
                CreatedFor      = new UserService(context).FindUserByEmail("*****@*****.**"),
            });
            ApplicationUser user = notification.CreatedFor;

            //Act
            var result = notificationService.FindNotificationsByUser(user);

            //Assert
            result.ForEach(n => Assert.AreEqual(user, n.CreatedFor));
        }
        public void ReadNotification_Valid()
        {
            // Arrange
            var notificationId = IdService.GetNewNotificationId(context);
            var expected       = 15; // Read status

            notificationService.Save(new Notification()
            {
                NotificationId  = notificationId,
                Status          = new StatusService(context).FindStatusByStatusId(14),
                CreatedDateTime = DateTime.Now
            });

            // Act
            var result = notificationService.ReadNotification(notificationId);

            // Assert
            Assert.AreEqual(expected, result.Status.StatusId);
        }
        public void FindNotificationsByTypeTest()
        {
            //Arrange
            var notificationId = IdService.GetNewNotificationId(context);
            var notification   = notificationService.Save(new Notification()
            {
                NotificationId   = notificationId,
                NotificationType = new NotificationTypeRepository(context).FindById(2),
                CreatedDateTime  = DateTime.Now
            });

            NotificationType type = notification.NotificationType;

            //Act
            var result = notificationService.FindNotificationByType(type);

            //Assert
            result.ForEach(n => Assert.AreEqual(type, n.NotificationType));
        }
        public void TestCleanup()
        {
            var usedNotificationId = IdService.GetNewNotificationId(context) - 1;

            if (notificationRepository.ExistsById(usedNotificationId))
            {
                notificationRepository.Delete(notificationRepository.FindById(usedNotificationId));
            }


            //delete test object from Disbursements
            List <Disbursement> ddlist = context.Disbursement.Where(x => x.DisbursementId == "TEST").ToList();

            foreach (Disbursement dd in ddlist)
            {
                disbursementRepository.Delete(dd);
            }

            //delete test object from Requisitions
            List <Requisition> rlist = context.Requisition.Where(x => x.RequisitionId == "TEST").ToList();

            foreach (Requisition r in rlist)
            {
                requisitionRepository.Delete(r);
            }

            //delete test object from StockAdjustments
            List <StockAdjustment> salist = context.StockAdjustment.Where(x => x.StockAdjustmentId == "TEST").ToList();

            foreach (StockAdjustment SA in salist)
            {
                saRepository.Delete(SA);
            }

            var retrievalRepository = new RetrievalRepository(context);

            if (retrievalRepository.ExistsById("NOTIFICATIONTEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("NOTIFICATIONTEST"));
            }
        }