Ejemplo n.º 1
0
        public void DuplicateApplyTest()
        {
            _leave = CreateLeave("Unit Test: Apply with overlapping date.");

            LeaveProcessComponent upc = new LeaveProcessComponent();

            // 1. Apply a new leave.
            _leave = upc.Apply(_leave);

            Assert.AreEqual(_leave.Status, LeaveStatuses.Pending, "Failed to apply new leave.");

            // Keep the previous workflow instance.
            Guid correlationId = _leave.CorrelationID;

            try
            {
                // 2. This will cause exception to occur.
                upc.Apply(_leave);
            }
            catch (ApplicationException ex)
            {
                if (ex.Message != "Date range is overlapping with another leave.")
                {
                    throw ex;
                }
            }

            // 3. Cancel it.
            // Need to do this, otherwise, there will be an orphaned workflow instance.
            _leave.CorrelationID = correlationId;
            upc.Cancel(_leave);

            _leave = upc.GetLeaveById(_leave.LeaveID);
            Assert.AreEqual(_leave.Status, LeaveStatuses.Cancelled, "Failed to cancel leave.");
        }
Ejemplo n.º 2
0
        public void ApplyThenRejectTest()
        {
            _leave = CreateLeave("Unit Test: Apply Then Reject");

            LeaveProcessComponent upc = new LeaveProcessComponent();

            // 1. Apply a new leave.
            _leave = upc.Apply(_leave);

            Assert.AreEqual(_leave.Status, LeaveStatuses.Pending, "Failed to apply new leave.");

            // 2. Reject it.
            upc.Reject(_leave);

            _leave = upc.GetLeaveById(_leave.LeaveID);
            Assert.AreEqual(_leave.Status, LeaveStatuses.Rejected, "Failed to reject leave.");
        }