예제 #1
0
 public void WhiteSpace_Should_Pass()
 {
     NewTestCollection()
     .Add(
         "Source.If().WhiteSpace",
         () => Source.If().WhiteSpace,
         12)
     .Add(
         "EmptySource.If().WhiteSpace",
         () => EmptySource.If().WhiteSpace,
         12)
     .RunAll();
 }
예제 #2
0
        public void EmptySourceCount()
        {
            tlog.Debug(tag, $"EmptySourceCount START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");
            Assert.AreEqual(testingTarget.Count, 0, "Count of EmptySource should be equal to 0.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceCount END (OK)");
        }
예제 #3
0
        public void EmptySourceGetPosition()
        {
            tlog.Debug(tag, $"EmptySourceGetPosition START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");
            Assert.AreEqual(testingTarget.GetPosition(0), -1, "The index of the first item of EmptySource should be -1.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceGetPosition END (OK)");
        }
예제 #4
0
        public void EmptySourceIsHeader()
        {
            tlog.Debug(tag, $"EmptySourceIsHeader START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");
            testingTarget.HasHeader = true;
            Assert.IsTrue(testingTarget.IsHeader(0), "The first item of EmptySource should is header.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceIsHeader END (OK)");
        }
예제 #5
0
        public void EmptySourceHasFooter()
        {
            tlog.Debug(tag, $"EmptySourceHasFooter START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.HasFooter = true;
            Assert.IsTrue(testingTarget.HasFooter, "EmptySource should have a footer.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceHasFooter END (OK)");
        }
예제 #6
0
        public void EmptySourceIsFooterWithHeader()
        {
            tlog.Debug(tag, $"EmptySourceIsFooterWithHeader START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");

            testingTarget.HasHeader = true;
            tlog.Debug(tag, "IsFooter : " + testingTarget.IsFooter(1));

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceIsFooterWithHeader END (OK)");
        }
예제 #7
0
 public void Not_Null_Or_WhiteSpace_Should_Pass()
 {
     NewTestCollection()
     .Add(
         "Source.If().Not.Null.Or.WhiteSpace",
         () => Source.If().Not.Null.Or.WhiteSpace,
         20)
     .Add(
         "EmptySource.If().Not.Null.Or.WhiteSpace",
         () => EmptySource.If().Not.Null.Or.WhiteSpace,
         20)
     .Add(
         "NullSource.If().Not.Null.Or.WhiteSpace",
         () => NullSource.If().Not.Null.Or.WhiteSpace,
         20)
     .RunAll();
 }
예제 #8
0
        private void cmdUpdate_Click(object source, EventArgs e)
        {
            AutoEvaluation eval = new AutoEvaluation();

            eval.ID          = Convert.ToInt32(lblEvalID.Text);
            eval             = (AutoEvaluation) new Evaluations(Globals.CurrentIdentity).GetInfo(eval.ID);
            eval.TimeLimit   = Convert.ToInt32(txtTimeLimit.Text);
            eval.RunToolArgs = txtRunArguments.Text;
            eval.RunTool     = ddlRunTool.SelectedItem.Text;

            eval.IsBuild        = chkBuild.Checked;
            eval.RunOnSubmit    = chkPretest.Checked;
            eval.Competitive    = chkCompete.Checked;
            eval.ToolVersion    = txtVersion.Text;
            eval.ToolVersioning = Convert.ToInt32(ddlVersioning.SelectedItem.Value);

            //Create deps if possible
            try {
                ucEvalDeps.Update(eval.ID, eval.AsstID);
            } catch (CustomException er) {
                PageJUnitError(er.Message);
                return;
            }

            //Create xtern source
            IExternalSource esrc;

            if (fuTester.PostedFile.ContentLength == 0)
            {
                esrc = new EmptySource();
            }
            else
            {
                esrc = CreateSource(fuTester.PostedFile);
            }

            //Upload files
            try {
                new Evaluations(Globals.CurrentIdentity).UpdateAuto(eval, esrc);
            } catch (CustomException er) {
                PageAutoError(er.Message);
            }

            BindAutoView(eval);
        }
예제 #9
0
 public void Length_Should_Pass()
 {
     NewTestCollection()
     .Add(
         "Source.If().Length.Is(5)",
         () => Source.If().Length.Is(5),
         20)
     .Add(
         "EmptySource.If().Length.Is(0)",
         () => EmptySource.If().Length.Is(0),
         20)
     .Add(
         "Source.If().Length.Is.Not(5)",
         () => Source.If().Length.Is.Not(5),
         20)
     .Add(
         "EmptySource.If().Length.Is.Not(0)",
         () => EmptySource.If().Length.Is.Not(0),
         20)
     .RunAll();
 }
예제 #10
0
        public void EmptySourceGetItem()
        {
            tlog.Debug(tag, $"EmptySourceGetItem START");

            var testingTarget = new EmptySource();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <EmptySource>(testingTarget, "should be an instance of testing target class!");

            try
            {
                var ret = testingTarget.GetItem(0);
            }
            catch (IndexOutOfRangeException e)
            {
                Assert.AreEqual(e.Message, "IItemSource is empty", "GetItem of EmptySource should not be implemented.");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"EmptySourceGetItem END (OK)");
        }
예제 #11
0
        /// <summary>
        ///     Create a baseline source for importing data into a tenant.
        /// </summary>
        /// <remarks>
        ///     Check the tenant to see if the root entity is present.
        ///     If it is, then perform an export to use the existing contents as a baseline, so it gets updated.
        ///     If it's not, then use an empty source so that everything gets added.
        /// </remarks>
        /// <param name="tenantId">Target tenant.</param>
        /// <param name="rootGuids">UpgradeID of entity to be targeted, if present.</param>
        /// <returns></returns>
        private IDataSource GetBaselineSourceForImport(long tenantId, IEnumerable <Guid> rootGuids)
        {
            IDataSource baseline;

            using (new TenantAdministratorContext(tenantId))
            {
                IDictionary <Guid, long> ids = UpgradeIdProvider.GetIdsFromUpgradeIds(rootGuids);

                if (ids.Count == 0)
                {
                    baseline = new EmptySource( );
                }
                else
                {
                    baseline = new TenantGraphSource
                    {
                        TenantId     = tenantId,
                        RootEntities = ids.Values.ToList( )
                    };
                }
            }
            return(baseline);
        }
예제 #12
0
        /// <summary>
        ///     Imports the tenant.
        /// </summary>
        /// <returns>the tenant id</returns>
        public static void InstallGlobalTenant( )
        {
            IProcessingContext context = new ProcessingContext( );

            context.Report.Action = AppLibraryAction.InstallGlobal;
            context.Report.Arguments.Add(new KeyValuePair <string, string>("Tenant Id", "Global"));

            IDictionary <Guid, Guid> appToAppVer = new Dictionary <Guid, Guid>( );

            // Get application versions
            // It is assumed that if there is no global tenant, then there is only one version of each of the core apps
            using (IDatabaseContext dbContext = DatabaseContext.GetContext(false))
                using (IDbCommand command = dbContext.CreateCommand())
                {
                    command.CommandText = "select FromUid AppUid, AppVerUid from AppRelationship where ToUid = @solution and TypeUid = @isOfType";
                    command.AddParameterWithValue("@solution", Guids.Solution);
                    command.AddParameterWithValue("@isOfType", Guids.IsOfType);

                    using (IDataReader reader = command.ExecuteReader( ))
                    {
                        // Load appVerId for apps from app library
                        while (reader.Read( ))
                        {
                            Guid appId    = reader.GetGuid(0);
                            Guid appVerId = reader.GetGuid(1);
                            appToAppVer[appId] = appVerId;
                        }
                    }
                }

            // Install apps
            Guid[] coreApps = new[]
            {
                Guids.CoreSolution,
                Guids.ConsoleSolution,
                Guids.CoreDataSolution,
                Guids.SystemSolution
            };

            // Copy system application content from the app library into the global tenant
            foreach (Guid appId in coreApps)
            {
                // Get the AppVerId
                Guid appVerId;
                if (!appToAppVer.TryGetValue(appId, out appVerId))
                {
                    throw new Exception($"Aborting: System app {0} was not present in app library.");
                }

                context.WriteInfo($"Installing app {appId} package {appVerId} to global tenant.");

                IDataSource empty  = new EmptySource( );
                IDataSource source = new LibraryAppSource
                {
                    AppId    = appId,
                    AppVerId = appVerId,
                    AppName  = appId.ToString( )
                };
                TenantMergeTarget target = new TenantMergeTarget
                {
                    TenantId = 0
                };

                using (empty)
                    using (source)
                        using ( target )
                        {
                            MergeProcessor processor = new MergeProcessor(context)
                            {
                                OldVersion = empty,
                                NewVersion = source,
                                Target     = target
                            };
                            processor.MergeData( );

                            target.Commit( );
                        }
            }


            // Copy metadata from the tenant back into the application library
            foreach (Guid appId in coreApps)
            {
                Guid appVerId = appToAppVer[appId];

                long        solutionEntityId = Entity.GetIdFromUpgradeId(appId);
                IDataSource metadataSource   = new TenantAppSource
                {
                    SolutionId = solutionEntityId,
                    TenantId   = 0
                };
                LibraryAppTarget metadataTarget = new LibraryAppTarget
                {
                    ApplicationVersionId = appVerId
                };
                using (metadataSource)
                    using ( metadataTarget )
                    {
                        CopyProcessor processor = new CopyProcessor(metadataSource, metadataTarget, context);
                        processor.CopyMetadataOnly = true;
                        processor.MigrateData( );

                        metadataTarget.Commit( );
                    }

                context.WriteInfo($"Installed app {appId} to global tenant.");
            }
        }
예제 #13
0
 public Logic(EmptySource <TOut> stage) : base(stage.Shape) => SetHandler(stage.Out, this);
예제 #14
0
        public void EmptySourceCountIsZero()
        {
            var emptySource = new EmptySource();

            Assert.That(emptySource.Count, Is.Zero);
        }
        private void ProcessRelateInstruction(ReaderContext context, ParseTreeNode relateInstructionNode)
        {
            AssertTerm(relateInstructionNode, DocTerms.RelateInstruction);
            AssertChildren(relateInstructionNode, 1, 2);

            // Determine the term name
            bool   isImplicitForEach = relateInstructionNode.ChildNodes[0].Term.Name == DocTerms.ListSource;
            string term;

            if (isImplicitForEach)
            {
                term = Keywords.With;
            }
            else
            {
                var behaviorNode = relateInstructionNode.ChildNodes[0];
                AssertTerm(behaviorNode, DocTerms.ListBehavior);
                AssertChildren(behaviorNode, 1);
                term = behaviorNode.ChildNodes[0].Token.ValueString;
            }

            // Process the list source
            ParseTreeNode sourceNode = relateInstructionNode.ChildNodes[isImplicitForEach ? 0 : 1];
            DataSource    source;

            string error = null;

            try
            {
                source = _parseTreeHelper.ConvertListSource(context, sourceNode);
            }
            catch (ParseException ex)
            {
                error  = ex.ShortMessage;
                source = new EmptySource();
            }
            catch (Exception ex)
            {
                error  = ex.Message;
                source = new EmptySource();
            }

            // And process the term
            Instruction instruction;

            switch (term)
            {
            case Keywords.With:
                instruction = ProcessForEachInstruction(context, source);
                break;

            case Keywords.If:
                instruction = ProcessIfInstruction(context, source);
                break;

            case Keywords.List:
                instruction = ProcessListInstruction(context, source);
                break;

            case Keywords.Rows:
                instruction = ProcessRowsInstruction(context, source);
                break;

            case Keywords.Force:
                throw new NotImplementedException();

            default:
                throw new InvalidOperationException(term);
            }

            if (instruction != null)
            {
                // Add the instruction (before push)
                AddInstruction(instruction);

                // Push the context
                _instructionStack.Push(instruction);

                if (error != null)
                {
                    instruction.HasUserError = true;
                    context.WriteErrorNoFlush(error);
                }
            }
            else
            {
                if (error != null)
                {
                    context.WriteError(error);
                }
            }
        }