public DashboardView()
        {
            InitializeComponent();

            AndonManager = new AndonManager(StationList, null, Andonmanager.AndonManager.MODE.MASTER);

            AndonManager.start();
            StationList = new Queue<int>();

            Plans = new Plans();
            PlanGrid.DataContext = Plans;

            Actuals = new Models.Actuals();
            ActualGrid.DataContext = Actuals;

            AppTimer = new Timer(1000);
            AppTimer.AutoReset = false;
            AppTimer.Elapsed += AppTimer_Elapsed;

            EfficiencyWatch = new Stopwatch();

            using (PSBContext DBContext = new PSBContext())
            {

                Shifts = DBContext.Shifts.ToList();

                foreach (Shift s in Shifts)
                {
                    s.Update();
                }

            }

            AppTimer.Start();
        }
Esempio n. 2
0
        public override TypeValidationResult CheckType()
        {
            foreach (var actual in Actuals)
            {
                var result = actual.CheckType();
                if (result.HasError)
                {
                    return(result);
                }
            }

            var functionType = SymbolTable.FunctionType(Name);

            if (functionType == null)
            {
                return(TypeValidationResult.Invalid(Position, $"Function '{Name}' has no definition"));
            }

            if (functionType.CheckArgs(Actuals.Select(a => a.Type)) == false)
            {
                return(TypeValidationResult.Invalid(Position, $"Function {Name}{functionType} called with mismatched arguments {Name}{ActualsTypeString}"));
            }

            SymbolTable.AddCaller(Name, SymbolTable.CurrentFunction);
            Type = functionType.ReturnType;
            return(TypeValidationResult.Valid(Type));
        }
Esempio n. 3
0
        public bool MarkCell(IEnumerable <object> actualValues, Tree <Cell> table, int rowsToSkip)
        {
            var actuals = new Actuals(actualValues);

            if (table.Branches.Count == rowsToSkip + 1 && actuals.UnmatchedCount == 0)
            {
                processor.TestStatus.MarkRight(table.ValueAt(rowsToSkip));
            }

            if (!FindMatches(table.Branches.Skip(rowsToSkip + 1), actuals))
            {
                return(false);
            }

            var rowCountBeforeSurplus = table.Branches.Count - rowsToSkip - 1;
            var result = true;

            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed)
            {
                actuals.ForSurplusValues(surplus => AddSurplusRow(surplus, table));
                result = false;
            }

            if (!MarkRows(table.Branches.Skip(rowsToSkip + 1).Take(rowCountBeforeSurplus), actuals))
            {
                result = false;
            }

            return(strategy.FinalCheck(processor.TestStatus) && result);
        }
Esempio n. 4
0
        bool MarkRows(IEnumerable <Tree <Cell> > expectedRows, Actuals actuals)
        {
            var markResult = true;
            var row        = 0;

            foreach (var markRow in expectedRows)
            {
                if (strategy.IsOrdered && actuals.IsOutOfOrder(row))
                {
                    MarkAsIncorrect(markRow, "out of order");
                    markResult = false;
                }
                else if (actuals.MatchValue(row) == null)
                {
                    MarkAsIncorrect(markRow, "missing");
                    markResult = false;
                }
                else
                {
                    var matchValues = strategy.ActualValues(actuals.MatchValue(row));
                    var cellNumber  = 0;
                    foreach (var cell in markRow.Branches)
                    {
                        if (matchValues[cellNumber].Type != typeof(void) || cell.Value.Text.Length > 0)
                        {
                            processor.Check(matchValues[cellNumber], cell);
                        }
                        cellNumber++;
                    }
                }
                row++;
            }
            return(markResult);
        }
Esempio n. 5
0
 bool MarkRows(IEnumerable<Tree<Cell>> expectedRows, Actuals actuals) {
     var markResult = true;
     var row = 0;
     foreach (var markRow in expectedRows) {
         if (strategy.IsOrdered && actuals.IsOutOfOrder(row)) {
             MarkAsIncorrect(markRow, "out of order");
             markResult = false;
         }
         else if (actuals.MatchValue(row) == null) {
             MarkAsIncorrect(markRow, "missing");
             markResult = false;
         }
         else {
             var matchValues = strategy.ActualValues(actuals.MatchValue(row));
             var cellNumber = 0;
             foreach (var cell in markRow.Branches) {
                 if (matchValues[cellNumber].Type != typeof(void) || cell.Value.Text.Length > 0) {
                     processor.Check(matchValues[cellNumber], cell);
                 }
                 cellNumber++;
             }
         }
         row++;
     }
     return markResult;
 }
Esempio n. 6
0
 public bool IsEqual(IEnumerable<object> actualValues, Tree<Cell> expectedValueCell) {
     var actuals = new Actuals(actualValues);
     var expectedRowNumber = 0;
     foreach (var expectedRow in expectedValueCell.Branches[0].Branches.Skip(1)) {
         var matchRowNumber = actuals.FindMatch(ExactMatch, expectedRowNumber, expectedRow);
         if (matchRowNumber == Actuals.Unmatched || (matchRowNumber != expectedRowNumber && strategy.IsOrdered)) return false;
         expectedRowNumber++;
     }
     return (actuals.UnmatchedCount == 0);
 }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="method"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public object HandleEventCall(IInvocation invocation, MethodInfo method, object[] arguments)
        {
            var actual = new Actuals(method, arguments);

            actuals.Add(actual);

            var subscription = (Delegate)arguments[0];

            HandleEventSubscription(method, subscription);

            var eventCollection = container
                                  .Where(x => x.Type == ExpectationType.Event)
                                  .ToArray();

            Expectation expectation = null;

            for (int entryIndex = 0; entryIndex < eventCollection.Length; entryIndex++)
            {
                var entry = eventCollection[entryIndex];
                if (!entry.MatchesCall(method, arguments))
                {
                    continue;
                }

                if (entry.ExpectationSatisfied)
                {
                    continue;
                }

                expectation = entry;
                break;
            }

            //NOTE: this could be where a "strict" mock call would throw an exception
            if (expectation == null)
            {
                return(HandleUnexpectedMethodCall(invocation, method, arguments));
            }

            RhinoMocks.Logger.LogExpectedMethodCall(invocation);
            expectation.AddActualCall(actual);

            if (expectation.ThrowsException)
            {
                throw expectation.ExceptionToThrow;
            }

            if (expectation.ForceProceed)
            {
                invocation.Proceed();
                return(invocation.ReturnValue);
            }

            return(expectation.ReturnValue);
        }
Esempio n. 8
0
 public bool IsEqual(object theActualValue, Parse theExpectedValueCell)
 {
     var actuals = new Actuals((IList)theActualValue, strategy);
     int expectedRow = 0;
     foreach (Parse currentRow in new CellRange(theExpectedValueCell.Parts.Parts.More).Cells) {
         int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
         if (match < 0 || (match != expectedRow && strategy.IsOrdered)) return false;
         expectedRow++;
     }
     return (actuals.UnmatchedCount == 0);
 }
Esempio n. 9
0
        public bool MarkCell(object systemUnderTest, object theActualValue, Parse theTableRows)
        {
            var actuals = new Actuals((IList)theActualValue, strategy);
            if (theTableRows.More == null && actuals.UnmatchedCount == 0) {
                processor.TestStatus.MarkRight(theTableRows);
            }
            bool result = true;
            int expectedRow = 0;
            foreach (Parse currentRow in new CellRange(theTableRows.More).Cells) {
                try {
                    int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                    if (match < 0) {
                        MarkAsIncorrect(currentRow, "missing");
                        result = false;
                    }
                    expectedRow++;
                }
                catch (Exception e) {
                    processor.TestStatus.MarkException(currentRow.Parts, e);
                    return false;
                }
            }
            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed) {
                actuals.ShowSurplus(processor, theTableRows.Last);
                result = false;
            }

            Parse markRow = theTableRows.More;
            for (int row = 0; row < expectedRow; row++) {
                if (strategy.IsOrdered && actuals.IsOutOfOrder(row)) {
                    MarkAsIncorrect(markRow, "out of order");
                    result = false;
                }
                else if (actuals.Match(row) != null) {
                    TypedValue[] actualValues = strategy.ActualValues(processor, actuals.Match(row));
                    int i = 0;
                    foreach (Parse cell in new CellRange(markRow.Parts).Cells) {
                        if (actualValues[i].Type != typeof(void) || cell.Text.Length > 0) {
                             new CellOperationImpl(processor).Check(systemUnderTest, actualValues[i], cell);

                        }
                        i++;
                    }
                }
                markRow = markRow.More;
            }

            if (!strategy.FinalCheck(processor.TestStatus)) return false;
            return result;
        }
Esempio n. 10
0
 bool FindMatches(IEnumerable<Tree<Cell>> expectedRows, Actuals actuals) {
     var expectedRow = 0;
     foreach (var currentRow in expectedRows) {
         try {
             actuals.FindMatch(BestMatch, expectedRow, currentRow);
             expectedRow++;
         }
         catch (System.Exception e) {
             processor.TestStatus.MarkException(currentRow.ValueAt(0), e);
             return false;
         }
     }
     return true;
 }
Esempio n. 11
0
        public bool IsEqual(IEnumerable <object> actualValues, Tree <Cell> expectedValueCell)
        {
            var actuals           = new Actuals(actualValues);
            var expectedRowNumber = 0;

            foreach (var expectedRow in expectedValueCell.Branches[0].Branches.Skip(1))
            {
                var matchRowNumber = actuals.FindMatch(ExactMatch, expectedRowNumber, expectedRow);
                if (matchRowNumber == Actuals.Unmatched || (matchRowNumber != expectedRowNumber && strategy.IsOrdered))
                {
                    return(false);
                }
                expectedRowNumber++;
            }
            return(actuals.UnmatchedCount == 0);
        }
Esempio n. 12
0
        public bool IsEqual(IEnumerable <object> theActualValue, Parse theExpectedValueCell)
        {
            var actuals     = new Actuals(theActualValue, strategy);
            int expectedRow = 0;

            foreach (Parse currentRow in new CellRange(theExpectedValueCell.Parts.Parts.More).Cells)
            {
                int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                if (match < 0 || (match != expectedRow && strategy.IsOrdered))
                {
                    return(false);
                }
                expectedRow++;
            }
            return(actuals.UnmatchedCount == 0);
        }
Esempio n. 13
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = (int)2166136261;
         hash = hash * 16777619 ^ CostCentre?.GetHashCode() ?? 0;
         hash = hash * 16777619 ^ Account?.GetHashCode() ?? 0;
         hash = hash * 16777619 ^ AccountName?.GetHashCode() ?? 0;
         hash = hash * 16777619 ^ Budget.GetHashCode();
         hash = hash * 16777619 ^ Profile.GetHashCode();
         hash = hash * 16777619 ^ Actuals.GetHashCode();
         hash = hash * 16777619 ^ Variance.GetHashCode();
         hash = hash * 16777619 ^ Forecast.GetHashCode();
         hash = hash * 16777619 ^ OutturnVariance.GetHashCode();
         return(hash);
     }
 }
Esempio n. 14
0
        bool FindMatches(IEnumerable <Tree <Cell> > expectedRows, Actuals actuals)
        {
            var expectedRow = 0;

            foreach (var currentRow in expectedRows)
            {
                try {
                    actuals.FindMatch(BestMatch, expectedRow, currentRow);
                    expectedRow++;
                }
                catch (System.Exception e) {
                    processor.TestStatus.MarkException(currentRow.ValueAt(0), e);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 15
0
        public bool MarkCell(IEnumerable<object> actualValues, Tree<Cell> table, int rowsToSkip) {
            var actuals = new Actuals(actualValues);
            if (table.Branches.Count == rowsToSkip + 1 && actuals.UnmatchedCount == 0) {
                processor.TestStatus.MarkRight(table.ValueAt(rowsToSkip));
            }

            if (!FindMatches(table.Branches.Skip(rowsToSkip + 1), actuals)) return false;

            var rowCountBeforeSurplus = table.Branches.Count - rowsToSkip - 1;
            var result = true;

            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed) {
                actuals.ForSurplusValues(surplus => AddSurplusRow(surplus, table));
                result = false;
            }

            if (!MarkRows(table.Branches.Skip(rowsToSkip + 1).Take(rowCountBeforeSurplus), actuals)) result = false;

            return strategy.FinalCheck(processor.TestStatus) && result;
        }
 // reset all values to default by initialization
 public void ResetAll()
 {
     actual = new Actuals();
 }
Esempio n. 17
0
        public bool MarkCell(IEnumerable <object> theActualValue, Parse theTableRows)
        {
            var actuals = new Actuals(theActualValue, strategy);

            if (theTableRows.More == null && actuals.UnmatchedCount == 0)
            {
                processor.TestStatus.MarkRight(theTableRows);
            }
            bool result      = true;
            int  expectedRow = 0;

            foreach (Parse currentRow in new CellRange(theTableRows.More).Cells)
            {
                try {
                    int match = actuals.FindMatch(RowMatches, expectedRow, currentRow.Parts);
                    if (match < 0)
                    {
                        MarkAsIncorrect(currentRow, "missing");
                        result = false;
                    }
                    expectedRow++;
                }
                catch (Exception e) {
                    processor.TestStatus.MarkException(currentRow.Parts, e);
                    return(false);
                }
            }
            if (actuals.UnmatchedCount > 0 && !strategy.SurplusAllowed)
            {
                actuals.ShowSurplus(processor, theTableRows.Last);
                result = false;
            }

            Parse markRow = theTableRows.More;

            for (int row = 0; row < expectedRow; row++)
            {
                if (strategy.IsOrdered && actuals.IsOutOfOrder(row))
                {
                    MarkAsIncorrect(markRow, "out of order");
                    result = false;
                }
                else if (actuals.Match(row) != null)
                {
                    TypedValue[] actualValues = strategy.ActualValues(actuals.Match(row));
                    int          i            = 0;
                    foreach (Parse cell in new CellRange(markRow.Parts).Cells)
                    {
                        if (actualValues[i].Type != typeof(void) || cell.Text.Length > 0)
                        {
                            new CellOperationImpl(processor).Check(actualValues[i], cell);
                        }
                        i++;
                    }
                }
                markRow = markRow.More;
            }

            if (!strategy.FinalCheck(processor.TestStatus))
            {
                return(false);
            }
            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// Handles a property call
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="method"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public object HandlePropertyCall(IInvocation invocation, MethodInfo method, object[] arguments)
        {
            var actual = new Actuals(method, arguments);

            actuals.Add(actual);

            var methodName  = method.Name;
            var propertyKey = GeneratePropertyKey(method, arguments);

            var propertyCollection = container
                                     .Where(x => x.Type == ExpectationType.Property)
                                     .ToArray();

            Expectation expectation = null;

            for (int entryIndex = 0; entryIndex < propertyCollection.Length; entryIndex++)
            {
                var entry = propertyCollection[entryIndex];
                if (!entry.MatchesCall(method, arguments))
                {
                    continue;
                }

                if (entry.ExpectationSatisfied)
                {
                    continue;
                }

                expectation = entry;
                break;
            }

            //NOTE: this could be where a "strict" mock call would throw an exception
            if (expectation == null)
            {
                RhinoMocks.Logger.LogUnexpectedMethodCall(invocation,
                                                          "Property: Dynamic handling of property.");
            }
            else
            {
                RhinoMocks.Logger.LogExpectedMethodCall(invocation);
                expectation.AddActualCall(actual);

                if (expectation.ThrowsException)
                {
                    throw expectation.ExceptionToThrow;
                }

                if (expectation.ForceProceed)
                {
                    invocation.Proceed();
                    return(invocation.ReturnValue);
                }

                if (methodName.StartsWith("get_", StringComparison.Ordinal))
                {
                    if (expectation.HasReturnValue)
                    {
                        return(expectation.ReturnValue);
                    }
                }
            }

            if (methodName.StartsWith("get_", StringComparison.Ordinal))
            {
                if (dynamicProperties.ContainsKey(propertyKey))
                {
                    return(dynamicProperties[propertyKey]);
                }
            }

            if (methodName.StartsWith("set_", StringComparison.Ordinal))
            {
                if (expectation != null && expectation.HasReturnValue)
                {
                    dynamicProperties[propertyKey] = expectation.ReturnValue;
                }
                else
                {
                    dynamicProperties[propertyKey] = arguments.Last();
                }
            }

            return(null);
        }
Esempio n. 19
0
        /// <summary>
        /// Handle a method call for the underlying mocked object
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="method"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public object HandleMethodCall(IInvocation invocation, MethodInfo method, object[] arguments)
        {
            if (arguments == null)
            {
                arguments = new object[0];
            }

            if (method.IsSpecialName)
            {
                var methodName = method.Name;
                if (methodName.StartsWith("get_", StringComparison.Ordinal) ||
                    methodName.StartsWith("set_", StringComparison.Ordinal))
                {
                    if (container.Any(x => x.Type == ExpectationType.Property))
                    {
                        return(HandlePropertyCall(invocation, method, arguments));
                    }
                }

                if (methodName.StartsWith("add_", StringComparison.Ordinal) ||
                    methodName.StartsWith("remove_", StringComparison.Ordinal))
                {
                    if (container.Any(x => x.Type == ExpectationType.Event))
                    {
                        return(HandleEventCall(invocation, method, arguments));
                    }
                }
            }

            var actual = new Actuals(method, arguments);

            actuals.Add(actual);

            var methodCollection = container
                                   .Where(x => x.Type == ExpectationType.Method)
                                   .ToArray();

            Expectation expectation = null;

            for (int entryIndex = 0; entryIndex < methodCollection.Length; entryIndex++)
            {
                var entry = methodCollection[entryIndex];
                if (!entry.MatchesCall(method, arguments))
                {
                    continue;
                }

                if (entry.ExpectationSatisfied)
                {
                    continue;
                }

                expectation = entry;
                break;
            }

            //NOTE: this could be where a "strict" mock call would throw an exception
            if (expectation == null)
            {
                for (int entryIndex = 0; entryIndex < methodCollection.Length; entryIndex++)
                {
                    var entry = methodCollection[entryIndex];
                    if (!entry.MatchesCall(method, arguments))
                    {
                        continue;
                    }

                    if (entry.ExpectationSatisfied)
                    {
                        entry.AddActualCall(actual);
                        continue;
                    }
                }

                return(HandleUnexpectedMethodCall(invocation, method, arguments));
            }

            RhinoMocks.Logger.LogExpectedMethodCall(invocation);
            expectation.AddActualCall(actual);

            if (expectation.HasDelegateToInvoke)
            {
                var methodParameters = method.GetParameters();

                var callback           = expectation.DelegateToInvoke;
                var callbackParameters = callback.Method.GetParameters();

                try
                {
                    if (callbackParameters.Length == 0)
                    {
                        var value = callback.DynamicInvoke(new object[0]);

                        if (callback.Method.ReturnType != (typeof(void)) &&
                            expectation.DelegateReturnsValue)
                        {
                            expectation.SetReturnValue(value);
                        }
                    }
                    else
                    {
                        var invokeCallback  = true;
                        var invokeArguments = new object[callbackParameters.Length];
                        for (int index = 0; index < callbackParameters.Length; index++)
                        {
                            var parameter     = callbackParameters[index];
                            var parameterType = parameter.ParameterType;

                            var argument     = methodParameters[index];
                            var argumentType = argument.ParameterType;

                            if (!parameterType.IsAssignableFrom(argumentType))
                            {
                                invokeCallback = false;
                                break;
                            }
                        }

                        if (invokeCallback)
                        {
                            var value = callback.DynamicInvoke(arguments);

                            if (callback.Method.ReturnType != (typeof(void)) &&
                                expectation.DelegateReturnsValue)
                            {
                                expectation.SetReturnValue(value);
                            }
                        }
                    }
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
            }

            if (expectation.ReturnArguments != null && expectation.ReturnArguments.Any())
            {
                var lenth      = expectation.ReturnArguments.Length;
                var parameters = method.GetParameters();
                for (int index = 0, returnIndex = 0; index < parameters.Length && returnIndex < lenth; index++)
                {
                    var parameter = parameters[index];
                    if (!parameter.IsOut && !parameter.ParameterType.IsByRef)
                    {
                        continue;
                    }

                    arguments[index] = expectation.ReturnArguments[returnIndex];
                    returnIndex++;
                }
            }

            if (expectation.ThrowsException)
            {
                throw expectation.ExceptionToThrow;
            }

            if (expectation.ForceProceed)
            {
                invocation.Proceed();

                if (expectation.HasDelegateToIntercept)
                {
                    expectation.DelegateToIntercept(new MethodInvocation(invocation));
                }

                return(invocation.ReturnValue);
            }

            invocation.ReturnValue = expectation.ReturnValue;

            if (expectation.HasDelegateToIntercept)
            {
                expectation.DelegateToIntercept(new MethodInvocation(invocation));
            }

            return(invocation.ReturnValue);
        }
Esempio n. 20
0
 public override String Print(int depth)
 {
     return(" new " + ClassName + "(" + Actuals.Print(depth) + ")");
 }
Esempio n. 21
0
 public override String Print(int depth)
 {
     return(Object.Print(depth) + "." + Method + "(" + Actuals.Print(depth) + ")");
 }
Esempio n. 22
0
 public override String Print(int depth)
 {
     return((Object == null ? "global" : Object.Print(depth))
            + "." + (string.IsNullOrEmpty(Method) ? SpecialFunc.Print(depth) : Method)
            + (Actuals == null ? string.Empty : "(" + Actuals.Print(depth) + ")"));
 }