Example #1
0
        public async Task PutAsyncTest()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId; nt.Description = "Announcement: 30 minutes to start the class";

            NotificationType expected = new NotificationType();

            expected.Description = "Announcement out of date";

            mockNotificationTypeRepository.Setup(r => r.FindById(notificationTypeId))
            .Returns(Task.FromResult <NotificationType>(nt));

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.UpdateAsync(notificationTypeId, expected);

            // Assert
            Assert.AreEqual(expected.Description, result.Resource.Description);
        }
Example #2
0
        public async Task GetAsyncTestUnhappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            var notificationTypeId = 1;

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.GetByIdAsync(notificationTypeId);

            var message = result.Message;

            // Assert
            message.Should().Be("Notification type not found");
        }
Example #3
0
        public async Task PostAsyncTestHappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId;

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.SaveAsync(nt);

            // Assert
            Assert.AreEqual(nt, result.Resource);
        }
Example #4
0
        public async Task DeleteAsyncTestHappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId;

            mockNotificationTypeRepository.Setup(r => r.FindById(notificationTypeId))
            .Returns(Task.FromResult <NotificationType>(nt));

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.DeleteAsync(notificationTypeId);

            // Assert
            Assert.AreEqual(nt, result.Resource);
        }