예제 #1
0
        /// <inheritdoc/>
        public void ErrorReasons(ICaller caller)
        {
            using IDealData data = InstanceFactory.GetInstance <IDealData>();

            if (data.AnyErrorReason())
            {
                return;
            }

            IList <IErrorReasonGroup> errorReasonGroups = data.ReadAllErrorReasonGroups();

            IErrorReasonGroup errorReasonGroupSet = errorReasonGroups
                                                    .Single(erg => erg.Code == "SET");
            IErrorReasonGroup errorReasonGroupPack = errorReasonGroups
                                                     .Single(erg => erg.Code == "PACK");

            IDictionary <string, string> errorReasonDetails = new Dictionary <string, string>
            {
                { "MULTIJAM", "Multi-card jam" },
                { "INVERTED", "Inverted card" },
                { "MISCOUNT", "Wrong number of cards in a hand" },
                { "MISSING", "Missing card" },
            };

            foreach (KeyValuePair <string, string> errorReasonGroupDetail in errorReasonDetails)
            {
                IErrorReason errorReason = new ErrorReason(
                    id: Guid.NewGuid(),
                    code: errorReasonGroupDetail.Key,
                    name: errorReasonGroupDetail.Value,
                    errorReasonGroup: errorReasonGroupSet);
                data.CreateErrorReason(errorReason);
            }

            errorReasonDetails = new Dictionary <string, string>
            {
                { "NOTKNOWN", "Card not recognised" },
                { "ALREADY-DEALT", "Card already dealt" },
                { "JAM", "Card jammed" }
            };

            foreach (KeyValuePair <string, string> errorReasonGroupDetail in errorReasonDetails)
            {
                IErrorReason errorReason = new ErrorReason(
                    id: Guid.NewGuid(),
                    code: errorReasonGroupDetail.Key,
                    name: errorReasonGroupDetail.Value,
                    errorReasonGroup: errorReasonGroupPack);
                data.CreateErrorReason(errorReason);
            }
        }