public void CancelDelegation_Valid()
        {
            // Arrange
            var controller = new DepartmentAPIController()
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration(),
                Context       = context,
            };

            delegationService.DelegateManagerRole("*****@*****.**", "*****@*****.**", "Sat Jul 28 00:00:00 GMT + 08:00 2018", "Sun Jul 29 00:00:00 GMT+08:00 2018");

            // Act
            var latestDelegation           = delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault();
            IHttpActionResult actionResult = controller.CancelDelegation(new CancelDelegationViewModel()
            {
                DelegationId = latestDelegation.DelegationId,
                HeadEmail    = "*****@*****.**",
            });
            var contentResult = actionResult as OkNegotiatedContentResult <MessageViewModel>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(contentResult.Content.Message, "Successfully cancelled");
            Assert.AreEqual(3, delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault().Status.StatusId);
        }
예제 #2
0
        public void DelegateManagerRole_Valid()
        {
            // Arrange

            // Act
            delegationService.DelegateManagerRole("*****@*****.**", "*****@*****.**", "Sat Jul 28 00:00:00 GMT + 08:00 2018", "Sun Jul 29 00:00:00 GMT+08:00 2018");

            // Assert
            Assert.IsTrue(userService.FindRolesByEmail("*****@*****.**").Contains("DepartmentHead"));
            Assert.AreEqual("*****@*****.**", delegationService.FindAllDelegations().OrderByDescending(d => d.DelegationId).FirstOrDefault().Receipient.Email);
        }