private static void AssertWorkStatus(WorkStatus status, WorkTable.WorkHandlerType handlerType)
        {
            var expectedWorkStatusId = _workTable.GetWorkStatusIdCodeFromMap(status);
            var actualWorkStatusId   = 0;

            actualWorkStatusId = _workTable.GetCurrentWorkStatusIdForHandlerType(handlerType);
            Assert.True(
                actualWorkStatusId.Equals(expectedWorkStatusId),
                "Work status id '" + actualWorkStatusId + "' is not equal to the expected one '" + expectedWorkStatusId + "'.");
        }
コード例 #2
0
        public void WaitAndAssertWorkStatus(WorkStatus expectedStatus, WorkTable.WorkHandlerType handlerType, double maxTimeToWait)
        {
            var sw = new Stopwatch();

            sw.Start();

            var expectedWorkStatusId = _workTable.GetWorkStatusIdCodeFromMap(expectedStatus);
            var actualWorkStatusId   = 0;
            var erroredWorkStatusId  = (int)WorkStatus.Errored;

            while (sw.Elapsed < TimeSpan.FromMinutes(maxTimeToWait))
            {
                //try
                //{
                //    AssertWorkStatus(status, handlerType);
                //    sw.Stop();
                //    return;
                //}
                //catch (AssertionException e)
                //{
                //    error = e.ToString();
                //}

                actualWorkStatusId = _workTable.GetCurrentWorkStatusIdForHandlerType(handlerType);

                if (expectedWorkStatusId != erroredWorkStatusId && actualWorkStatusId == erroredWorkStatusId)
                {
                    Assert.True(actualWorkStatusId.Equals(expectedWorkStatusId), "Work Status is Errored and it was not expected. Expected Work Status: '" + Enum.GetName(typeof(WorkStatus), expectedWorkStatusId) + "'. Waiting time (minutes): " + maxTimeToWait);
                }
                if (actualWorkStatusId.Equals(expectedWorkStatusId))
                {
                    sw.Stop();
                    return;
                }
            }
            sw.Stop();
            Assert.True(actualWorkStatusId.Equals(expectedWorkStatusId), "Work status '" + Enum.GetName(typeof(WorkStatus), actualWorkStatusId) + "' is not equal to the expected one '" + Enum.GetName(typeof(WorkStatus), expectedWorkStatusId) + "'. Waiting time (minutes): " + maxTimeToWait);
            //throw new AssertionException(error);
        }