예제 #1
0
        public ActionResult Details(int id,
                                    int pPage       = 1,
                                    string myUser   = null,
                                    string mySearch = null)
        {
            var db    = new CodeItDbContext();
            var code  = db.Codes.Where(c => c.Id == id).FirstOrDefault();
            var lines = code.CodeContent.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            var comments = db.Comments.Where(c => c.CodeId == id).ToList();
            var viewCode = new CodeDetails
            {
                Id          = id,
                Author      = code.Author.Nickname,
                CodeTitle   = code.CodeTitle,
                CodeContent = lines,
                PrevPage    = pPage,
                ContactInfo = code.Author.Email,
                Coments     = comments,
                AuthorId    = code.AuthorId,
                MyUser      = myUser,
                TimeCreated = code.TimeCreated,
                MySearch    = mySearch
            };


            if (code == null)
            {
                return(HttpNotFound());
            }

            return(View(viewCode));
        }
예제 #2
0
        /// <summary>
        /// This method should be called from within the test method.
        /// It uses reflection to get the calling method name and it expects
        /// to recieve a reference of the test class to get the name of the
        /// feature and namespace.
        /// </summary>
        /// <param name="scenarioName">
        /// The name of the scenario to create.  Use this to override the method
        /// name from becoming the scenario name.
        /// </param>
        /// <param name="featureClass">
        /// A reference to the parent class for the scenario.
        /// Usually just pass in 'this'.  The test class represents the feature.
        /// </param>
        /// <param name="methodName">Optional. The system will attempt to get the method name of the scenario through reflection.</param>
        /// <param name="sortOrder">Optional. Used by the test run when sorting the results
        /// if you call SortTestRunResults on the test run. Default value is 1,000,000</param>
        /// <returns>The scenario build for a fluent syntax.</returns>
        public ScenarioBuilder AddScenario(string scenarioName,
                                           object featureClass, int sortOrder = 1000000, [CallerMemberName] string methodName = "")
        {
            CodeDetails codeDetails = factory.UtilityFactory.GetMethodRetriever().GetScenarioMethod(featureClass, methodName);

            return(AddScenario(codeDetails, scenarioName, null, null, sortOrder));
        }
예제 #3
0
파일: xB.cs 프로젝트: Stewartarmbrecht/xBDD
        /// <summary>
        /// This method should be called from within the test method.
        /// It uses reflection to get the calling method name and it expects
        /// to recieve a reference of the test class to get the name of the
        /// feature and namespace.
        /// </summary>
        /// <param name="featureClass">
        /// A reference to the parent class that implements the Ifeature interface for the scenario.
        /// Usually just pass in 'this'.  The test class represents the feature.ß
        /// </param>
        /// <param name="methodName">Optional. The system will attempt to get the method name of the scenario through reflection.</param>
        /// <param name="sortOrder">Optional. Used by the test run when sorting the results
        /// if you call SortTestRunResults on the test run. Default value is 1,000,000.</param>
        /// <returns>The scenario build for a fluent syntax.</returns>
        public static ScenarioBuilder AddScenario(object featureClass, int sortOrder = 0, [CallerMemberName] string methodName = "")
        {
            //TODO: Fix hack to ensure factory exists.
            var         currentRun  = xB.CurrentRun;
            CodeDetails codeDetails = factory.UtilityFactory.GetMethodRetriever().GetScenarioMethod(featureClass, methodName);

            return(xB.CurrentRun.AddScenario(codeDetails, null, null, null, sortOrder));
        }
예제 #4
0
        public CodeManager()
        {
            Author[] author = new Author[1];
            string[] description = new string[1];
            CodeRepresentative selfRepresentative = new CodeRepresentative();

            author[0] = new Author("Maciej 'Expro' Grabowski", "*****@*****.**");
            description[0] = "Dynamic code manager, extends application features with modules and plugins.";
            managerDetails = new CodeDetails(Environment.GetCommandLineArgs()[0], typeof(CodeManager).FullName);
            managerDetails.Authors = author;
            managerDetails.Descriptions = description;
            managerDetails.IsModule = true;
            managerDetails.IsShared = true;
            managerDetails.Version = new CodeVersion(1, 0, 0);
            managerDetails.Name = "Code Manager";

            selfRepresentative.Details = managerDetails;
            selfRepresentative.Instance = this;
            selfRepresentative.Provider = this;
            selfRepresentative.State = CodeState.Created;

            modulePermissions = new PermissionSet(PermissionState.Unrestricted);

            addinPermissions = new PermissionSet(PermissionState.Unrestricted);
            addinPermissions.AddPermission(new UIPermission(PermissionState.Unrestricted));
            addinPermissions.AddPermission(new IsolatedStorageFilePermission(PermissionState.Unrestricted));

            SeparateModules = false;

            binaries = ";";
            memoryManagement = MemoryMode.FastestInitialization;

            codes = new SortedSet<CodeDetails>();
            shared = new SortedSet<CodeDetails>();
            modules = new SortedSet<CodeDetails>();
            addins = new SortedSet<CodeDetails>();
            controllable = new SortedSet<CodeDetails>();
            conditions = new SortedSet<string>();
            resolver = new SortedDictionary<string, CodeDetails>();
            representatives = new SortedDictionary<CodeDetails, CodeRepresentative>();
            domains = new SortedDictionary<CodeDetails, AppDomain>();
            files = new SortedSet<string>();
            modulesLock = new SemaphoreSlim(2);

            resolver.Add(typeof(CodeManager).FullName, managerDetails);
            domains.Add(managerDetails, AppDomain.CurrentDomain);
            representatives.Add(managerDetails, selfRepresentative);
            codes.Add(managerDetails);
            shared.Add(managerDetails);
            modules.Add(managerDetails);
        }
예제 #5
0
        private ScenarioBuilder AddScenario(
            string capabilityName,
            string featureName,
            string scenarioName,
            string asAStatement,
            string soThatStatement,
            string youCanStatement,
            string scenarioExplanation,
            TextFormat scenarioExplanationFormat,
            string featureExplanation,
            TextFormat featureExplanationFormat)
        {
            this.scenarioCount++;
            var         namespaceName       = $"{this.rootNamespace}.{capabilityName.ConvertCapabilityNameToNamespace()}";
            var         className           = featureName.ConvertFeatureNameToClassName();
            var         featureAssignments  = featureName.ExtractAssignments();
            var         featureTags         = featureName.ExtractTags();
            var         reason              = scenarioName.ExtractReason();
            var         scenarioAssignments = scenarioName.ExtractAssignments();
            var         scenarioTags        = scenarioName.ExtractTags();
            var         methodName          = scenarioName.ConvertScenarioNameToMethodName();
            CodeDetails codeDetails         = new CodeDetails(
                namespaceName,
                className,
                methodName,
                asAStatement,
                soThatStatement,
                youCanStatement,
                scenarioExplanation,
                scenarioExplanationFormat,
                featureExplanation,
                featureExplanationFormat,
                scenarioAssignments,
                scenarioTags,
                featureAssignments,
                featureTags);
            var scenarioBuilder = xB.CurrentRun.AddScenario(codeDetails, this.scenarioCount * 1000);

            scenarioBuilder.Scenario.Reason = reason;
            if (scenarioBuilder.Scenario.Reason == "Failed")
            {
                scenarioBuilder.Scenario.Outcome = Outcome.Failed;
            }
            else if (scenarioBuilder.Scenario.Reason != null)
            {
                scenarioBuilder.Scenario.Outcome = Outcome.Skipped;
            }
            return(scenarioBuilder);
        }
 /// <summary>
 /// Gets the code and occurence value.
 /// </summary>
 /// <param name="uploadedValue">The uploaded value.</param>
 /// <param name="codeDetailsList">The codes.</param>
 /// <param name="claimCharge">The claim charge.</param>
 /// <param name="codeDetails">The code details.</param>
 private void GetCodeAndOccurenceValue(ClaimFieldValue uploadedValue, IEnumerable <CodeDetails> codeDetailsList,
                                       ClaimCharge claimCharge, CodeDetails codeDetails)
 {
     if (!PaymentTypeCustomTable.IsPerDayOfStay)
     {
         CodeDetails perCode = codeDetailsList.First(
             pday => pday.Code == uploadedValue.Identifier);
         codeDetails.Occurence = perCode.Occurence;
         codeDetails.Code      = perCode.Code;
         codeDetails.Limit     = perCode.Limit;
     }
     else
     {
         CodeDetails perDayOfStay = codeDetailsList.First(
             pday => pday.Code == uploadedValue.Identifier && pday.Day == claimCharge.ServiceFromDate);
         codeDetails.Occurence = perDayOfStay.Occurence;
         codeDetails.Code      = perDayOfStay.Code;
         codeDetails.Limit     = perDayOfStay.Limit;
     }
 }
예제 #7
0
        internal Feature GetOrCreate(Capability capability, string name, CodeDetails codeDetails)
        {
            var feature = features.Where(x => x.Name == name && x.Capability == capability).FirstOrDefault();

            if (feature == null)
            {
                feature = factory.CreateFeature(name, capability);
                if (codeDetails != null)
                {
                    feature.AsA               = codeDetails.GetFeatureAsAStatement();
                    feature.YouCan            = codeDetails.GetFeatureYouCanStatement();
                    feature.SoThat            = codeDetails.GetFeatureSoThatStatement();
                    feature.FullClassName     = codeDetails.GetFullClassName();
                    feature.Explanation       = codeDetails.GetFeatureExplanation();
                    feature.ExplanationFormat = codeDetails.GetFeatureExplanationFormat();
                    feature.Assignments       = codeDetails.GetFeatureAssignments();
                    feature.Tags              = codeDetails.GetFeatureTags();
                }
                features.Add(feature);
            }
            return(feature);
        }
        /// <summary>
        /// Evaluates the line by occurence.
        /// </summary>
        /// <param name="claimPaymentResult">The claim payment result.</param>
        /// <param name="claim">The claim.</param>
        /// <param name="codeDetailsList">The codes.</param>
        /// <param name="claimCharge">The claim charge.</param>
        /// <param name="claimFieldDocValueDictionary">The claim field document value dictionary.</param>
        /// <param name="formula">The formula.</param>
        /// <param name="uploadedValue">The uploaded value.</param>
        private void EvaluateLineByOccurence(PaymentResult claimPaymentResult, IEvaluateableClaim claim,
                                             List <CodeDetails> codeDetailsList, ClaimCharge claimCharge, Dictionary <string, string> claimFieldDocValueDictionary,
                                             double?formula, ClaimFieldValue uploadedValue)
        {
            bool isMultiplierexist = PaymentTypeCustomTable.MultiplierFirst != null || PaymentTypeCustomTable.MultiplierSecond != null ||
                                     PaymentTypeCustomTable.MultiplierThird != null || PaymentTypeCustomTable.MultiplierFourth != null ||
                                     PaymentTypeCustomTable.MultiplierOther != null;

            for (int unit = 0; unit < ((!PaymentTypeCustomTable.IsObserveServiceUnit && !isMultiplierexist) ? 1 : claimCharge.Units); unit++)
            {
                CodeDetails codeDetails = new CodeDetails();
                GetCodeAndOccurenceValue(uploadedValue, codeDetailsList, claimCharge, codeDetails);
                if ((PaymentTypeCustomTable.IsObserveServiceUnit && codeDetails.Limit > 0) ||
                    (PaymentTypeCustomTable.IsObserveServiceUnit &&
                     PaymentTypeCustomTable.ObserveServiceUnitLimit == null) || !PaymentTypeCustomTable.IsObserveServiceUnit)
                {
                    switch (codeDetails.Occurence)
                    {
                    case 1:
                        string multiplierFirstExpandedExpression = PaymentTypeCustomTable.MultiplierFirst ??
                                                                   Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierFirstExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 2:
                        string multiplierSecondExpandedExpression = PaymentTypeCustomTable.MultiplierSecond ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierSecondExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 3:
                        string multiplierThirdExpandedExpression = PaymentTypeCustomTable.MultiplierThird ??
                                                                   Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierThirdExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 4:
                        string multiplierFourthExpandedExpression = PaymentTypeCustomTable.MultiplierFourth ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierFourthExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    default:
                        string multiplierOthersExpandedExpression = PaymentTypeCustomTable.MultiplierOther ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierOthersExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;
                    }
                }
                else if (claimPaymentResult.AdjudicatedValue == null)
                {
                    claimPaymentResult.ClaimStatus      = (byte)Enums.AdjudicationOrVarianceStatuses.Adjudicated;
                    claimPaymentResult.AdjudicatedValue = 0.0;
                }
            }
        }
예제 #9
0
 /// <summary>
 /// This method should be called from within the test method.
 /// This signature allows you to set properties of the scenario
 /// that would otherwise be set by the code.
 /// </summary>
 /// <param name="codeDetails">
 /// Provides ability to set details that would otherwise be pulled
 /// from the feature class code.
 /// </param>
 /// <param name="sortOrder">Optional. Used by the test run when sorting the results
 /// if you call SortTestRunResults on the test run. Default value is 1,000,000.</param>
 /// <returns>The scenario build for a fluent syntax.</returns>
 public ScenarioBuilder AddScenario(CodeDetails codeDetails, int sortOrder = 100000)
 {
     return(AddScenario(codeDetails, null, null, null, sortOrder));
 }
예제 #10
0
        private CodeDetails RetriveDetails(Type type)
        {
            Contract.Requires(type != null);
            Contract.Ensures(Contract.Result<CodeDetails>() != null);

            CodeDetails result = new CodeDetails(path, type.FullName);
            object[] attributes = type.GetCustomAttributes(true);
            Type[] allInterfaces = type.GetInterfaces();
            ISet<Author> authors = new HashSet<Author>();
            ISet<string> description = new HashSet<string>();
            ISet<string> interfaces = new HashSet<string>();

            if (typeof(IControllableCode).IsAssignableFrom(type))
                result.IsControllable = true;

            if (typeof(SharedCode).IsAssignableFrom(type))
                result.IsShared = true;

            if (typeof(MarshalByRefObject).IsAssignableFrom(type))
                result.IsShared = true;

            foreach (object attribute in attributes)
            {
                if (attribute is NameAttribute)
                    result.Name = (attribute as NameAttribute).Value;

                if (attribute is DescriptionAttribute)
                    description.Add((attribute as DescriptionAttribute).Text);

                if (attribute is AuthorAttribute)
                {
                    var authorAttribute = (AuthorAttribute)attribute;
                    authors.Add(new Author(authorAttribute.Name, authorAttribute.Email));
                }

                if (attribute is VersionAttribute)
                {
                    var versionAttribute = (VersionAttribute)attribute;
                    result.Version = new CodeVersion(versionAttribute.Major, versionAttribute.Minor, versionAttribute.Build);
                }

                if (attribute is ModuleAttribute)
                {
                    result.IsModule = true;
                    result.ModuleCondition = (attribute as ModuleAttribute).Condition;
                }
            }

            foreach (Type iface in allInterfaces)
                interfaces.Add(iface.FullName);

            var authorsArray = new Author[authors.Count];
            authors.CopyTo(authorsArray, 0);
            result.Authors = authorsArray;

            var descriptionArray = new string[description.Count];
            description.CopyTo(descriptionArray, 0);
            result.Descriptions = descriptionArray;

            var interfacesArray = new string[interfaces.Count];
            interfaces.CopyTo(interfacesArray, 0);
            result.Interfaces = interfacesArray;

            return result;
        }
예제 #11
0
        private void DistibuteToCategories(CodeDetails details)
        {
            Contract.Requires(details != null);

            ICollection<string> ifaces = details.Interfaces;

            if (details.ClassName.Equals(typeof(CodeManager).FullName))
                return;

            try
            {
                codes.Add(details);

                if (details.IsShared)
                    shared.Add(details);

                if (details.IsModule)
                    modules.Add(details);
                else
                    addins.Add(details);

                if (details.IsControllable)
                    controllable.Add(details);

                resolver.Add(details.ClassName, details);
                foreach (string iface in ifaces)
                {
                    if (!resolver.ContainsKey(iface))
                        resolver.Add(iface, details);
                }
            }
            catch (Exception e)
            {
                LoggingService.Trace.Error(e.ToString(), new string[] {"EXCEPTION", "RESOURCE"}, this);

                if (codes.Contains(details))
                    codes.Remove(details);

                if (shared.Contains(details))
                    shared.Remove(details);

                if (modules.Contains(details))
                    modules.Remove(details);

                if (controllable.Contains(details))
                    controllable.Remove(details);
            }
        }
예제 #12
0
 protected internal void Unload(CodeDetails details)
 {
     UnloadDomain(details);
     representatives.Remove(details);
 }
예제 #13
0
        protected internal CodeRepresentative ProvideRepresentative(CodeDetails details)
        {
            Contract.Requires(details != null);
            Contract.Ensures(Contract.Result<CodeRepresentative>() != null);

            AppDomain domain;
            CodeRepresentative result;
            CrossDomainLoggingAccessor loggingAccessor;

            if (!representatives.ContainsKey(details))
            {
                if (!details.IsModule)
                    domain = CreateAddinDomain(String.Format("Domain for addin {0}.", details.Name));
                else
                {
                    if (SeparateModules)
                        domain = CreateModuleDomain(String.Format("Domain for module {0}.", details.Name));
                    else
                        domain = modulesDomain;
                }

                if (details.IsControllable)
                    result = (CodeRepresentative)domain.CreateInstanceAndUnwrap(typeof(ControllableCodeRepresentative).Assembly.FullName, typeof(ControllableCodeRepresentative).FullName);
                else
                    result = (CodeRepresentative)domain.CreateInstanceAndUnwrap(typeof(CodeRepresentative).Assembly.FullName, typeof(CodeRepresentative).FullName);

                result.Details = details;
                result.Provider = this;
                loggingAccessor = (CrossDomainLoggingAccessor)domain.CreateInstanceAndUnwrap(typeof(CrossDomainLoggingAccessor).Assembly.FullName, typeof(CrossDomainLoggingAccessor).FullName);
                loggingAccessor.LocalDebugLoggingService.Parent = LoggingService.Debug;
                loggingAccessor.LocalTraceLoggingService.Parent = LoggingService.Trace;

                representatives.Add(details, result);
                domains.Add(details, domain);
            }
            else
                result = representatives[details];

            return result;
        }
예제 #14
0
        protected internal CodeRepresentative GetRepresentative(CodeDetails details)
        {
            Contract.Requires(details != null);

            if (representatives.ContainsKey(details))
                return representatives[details];
            else
                return null;
        }
예제 #15
0
        public ICodeController GetController(CodeDetails details)
        {
            Contract.Requires(details != null);

            if (codes.Contains(details))
            {
                if (!details.IsControllable)
                    return new CodeController(this, details);
                else
                    return new ControllableCodeController(this, details);
            }
            else
                return null;
        }
예제 #16
0
        public static async Task <TestRun> BuildTestRun(
            List <string> failingStepIds = null,
            Dictionary <string, string> skippedScenarioIdsAndReasons = null)
        {
            for (int capabilityCount = 1; capabilityCount <= 3; capabilityCount++)
            {
                for (int featureCount = 1; featureCount <= 3; featureCount++)
                {
                    for (int scenarioCount = 1; scenarioCount <= 3; scenarioCount++)
                    {
                        var scenarioId  = $"{capabilityCount.ToString().PadLeft(2,'0')}{featureCount.ToString().PadLeft(2,'0')}{scenarioCount.ToString().PadLeft(2,'0')}";
                        var codeDetails = new CodeDetails(
                            $"Capability{capabilityCount.ToString().PadLeft(2,'0')}",
                            $"Feature{capabilityCount.ToString().PadLeft(2,'0')}{featureCount.ToString().PadLeft(2,'0')}",
                            $"Scenario{scenarioId}",
                            $"As a user",
                            $"So that you get some value",
                            $"You can perform some action",
                            null,
                            TextFormat.text,
                            null,
                            TextFormat.text,
                            null,
                            null,
                            null,
                            null
                            );
                        var    scenario   = xB.CurrentRun.AddScenario(codeDetails, scenarioCount);
                        string skipReason = null;
                        if (skippedScenarioIdsAndReasons != null && skippedScenarioIdsAndReasons.ContainsKey(scenarioId))
                        {
                            skipReason = skippedScenarioIdsAndReasons[scenarioId];
                        }
                        for (int stepCount = 1; stepCount <= 3; stepCount++)
                        {
                            var stepId = $"{capabilityCount.ToString().PadLeft(2,'0')}{featureCount.ToString().PadLeft(2,'0')}{scenarioCount.ToString().PadLeft(2,'0')}{stepCount.ToString().PadLeft(2,'0')}";
                            var fail   = false;
                            if (failingStepIds != null)
                            {
                                fail = failingStepIds.Contains(stepId);
                            }
                            Step step = xB.CreateAsyncStep(
                                $"Step{stepId}",
                                null,
                                @"This 
is 
multiline 
text.",
                                TextFormat.text
                                );
                            if (fail)
                            {
                                step.ActionAsync = async(s) => { await Task.Run(() => { throw new System.Exception("My exception"); }); };
                            }
                            else
                            {
                                step.ActionAsync = async(s) => { await Task.Run(() => {
                                        step.Output       = @"This
is
multiline
output";
                                        step.OutputFormat = TextFormat.sh;
                                    }); };
                            }
                            switch (stepCount)
                            {
                            case 1:
                                scenario.Given(step);
                                break;

                            case 2:
                                scenario.When(step);
                                break;

                            case 3:
                                scenario.Then(step);
                                break;
                            }
                        }
                        try {
                            if (skipReason != null)
                            {
                                await scenario.Skip(skipReason, Assert.Inconclusive);
                            }
                            await scenario.Run();
                        } catch {
                        }
                    }
                }
            }

            return(xB.CurrentRun.TestRun);
        }
예제 #17
0
        private CodeDetails[] RetriveDetails(string file)
        {
            Contract.Requires(file != null);

            AppDomain analizeDomain;
            AppDomainSetup info = new AppDomainSetup();
            CodeAnalizer analizer;
            CodeDetails[] result;

            info.ApplicationBase = Environment.CurrentDirectory;
            info.PrivateBinPath = binaries;

            analizeDomain = AppDomain.CreateDomain("Analize Sandbox", null, info, ModulePermissions, null);

            analizer = (CodeAnalizer)analizeDomain.CreateInstanceAndUnwrap(typeof(CodeAnalizer).Assembly.FullName, typeof(CodeAnalizer).FullName);
            analizer.Path = file;
            analizer.Analize();

            result = new CodeDetails[analizer.Codes.Count];
            analizer.Codes.CopyTo(result, 0);

            AppDomain.Unload(analizeDomain);

            return result;
        }
예제 #18
0
        private void UnloadDomain(CodeDetails details, int attempts = 3)
        {
            try
            {
                if (attempts != 0)
                {
                    if (!details.Equals(managerDetails))
                    {
                        representatives[details].Destroy();
                        AppDomain.Unload(domains[details]);
                    }
                }
                else
                    LoggingService.Trace.Warning("Unloading domain for " + details.ToString() + " failed during all attemps. Domain will be ignored.", new string[] {"CODE"}, this);
            }
            catch (CannotUnloadAppDomainException e)
            {
                --attempts;
                LoggingService.Trace.Error(e.ToString(), new string[] {"EXCEPTION"}, this);
                if (attempts != 0)
                    LoggingService.Trace.Warning("Unloading domain for " + details.ToString() + " failed. Trying again (" + attempts.ToString() + " more attempts left).", new string[] {"CODE"}, this);

                UnloadDomain(details, attempts);
            }
            catch (AppDomainUnloadedException e)
            {
                LoggingService.Trace.Warning(e.ToString(), new string[] {"EXCEPTION"}, this);
                LoggingService.Trace.Warning("Detected attempt to unloaded domain. Removing data assosiated with referenced domain.", new string[] {"CODE"}, this);

                if (representatives.ContainsKey(details))
                    representatives.Remove(details);
            }
            catch (Exception e)
            {
                LoggingService.Trace.Error(e.ToString(), new string[] {"EXCEPTION"}, this);
            }
            finally
            {
                if (domains.ContainsKey(details))
                    domains.Remove(details);

                if (representatives.ContainsKey(details))
                    representatives.Remove(details);
            }
        }
 public ControllableCodeController(CodeManager manager, CodeDetails details)
     : base(manager, details)
 {
 }
예제 #20
0
        internal ScenarioBuilder AddScenario(
            CodeDetails codeDetails,
            string scenarioName,
            string featureName,
            string capabilityName,
            int sortOrder)
        {
            if (scenarioName == null && codeDetails != null)
            {
                scenarioName = codeDetails.Name.AddSpacesToSentence();
            }

            if (featureName == null && codeDetails != null)
            {
                featureName = codeDetails.GetClassName().AddSpacesToSentence();
            }

            if (capabilityName == null && codeDetails != null)
            {
                capabilityName = codeDetails.GetNameSpace().AddSpacesToSentence();
            }

            var methodName = scenarioName;

            if (codeDetails != null)
            {
                methodName = codeDetails.Name;
            }

            string scenarioExplanation = null;

            if (codeDetails != null)
            {
                scenarioExplanation = codeDetails.GetScenarioExplanation();
            }

            TextFormat scenarioExplanationFormat = TextFormat.text;

            if (codeDetails != null)
            {
                scenarioExplanationFormat = codeDetails.GetScenarioExplanationFormat();
            }

            string[] scenarioAssignments = null;
            if (codeDetails != null)
            {
                scenarioAssignments = codeDetails.GetScenarioAssignments();
            }

            string[] scenarioTags = null;
            if (codeDetails != null)
            {
                scenarioTags = codeDetails.GetScenarioTags();
            }

            var capability = capabilityCache.GetOrCreate(TestRun, capabilityName);
            var feature    = featureCache.GetOrCreate(capability, featureName, codeDetails);

            return(factory.CreateScenarioBuilder(
                       scenarioName,
                       feature,
                       methodName,
                       scenarioExplanation,
                       scenarioExplanationFormat,
                       scenarioAssignments,
                       scenarioTags,
                       sortOrder));
        }