コード例 #1
0
        void SetUpSUT(string memberName)
        {
            this.memberName = memberName;
            testStatus      = new TestStatus();
            processor       = new Mock <CellProcessor>();
            execute         = new ExecuteDefault {
                Processor = processor.Object
            };
            check = new CheckDefault {
                Processor = processor.Object
            };
            memory = new TypeDictionary();

            target = new TypedValue("target");
            result = new TypedValue("result");

            targetCell = new CellTreeLeaf("stuff");

            processor
            .Setup(p => p.Parse(typeof(MemberName), It.IsAny <TypedValue>(), It.Is <CellTreeLeaf>(c => c.Text == memberName)))
            .Returns(new TypedValue(new MemberName(memberName)));
            processor
            .Setup(p => p.Invoke(target, It.Is <MemberName>(m => m.Name == "member"), It.Is <Tree <Cell> >(c => c.Branches.Count == 0)))
            .Returns(result);
            processor
            .Setup(p => p.Invoke(It.Is <TypedValue>(v => v.ValueString == "target"), It.Is <MemberName>(m => m.Name == "procedure"), It.IsAny <Tree <Cell> >()))
            .Returns((TypedValue t, MemberName m, Tree <Cell> c) => {
                testStatus.Counts.AddCount(TestStatus.Right);
                testStatus.LastAction = "blah blah";
                return(result);
            });
            processor.Setup(p => p.Compare(It.IsAny <TypedValue>(), It.IsAny <Tree <Cell> >())).Returns(true);
            processor.Setup(p => p.TestStatus).Returns(testStatus);
            processor.Setup(p => p.Memory).Returns(memory);
        }
コード例 #2
0
            public Tree <Cell> Compose(TypedValue instance)
            {
                var cell = new CellTreeLeaf("stuff");

                cell.Value.SetAttribute(CellAttribute.Add, string.Empty);
                return(cell);
            }
コード例 #3
0
 public void AddsSymbolValueToCellAttributes()
 {
     var cell = new CellTreeLeaf("<<symbol");
     var processor = new CellProcessorBase();
     processor.Store(new Symbol("symbol", "value"));
     new ParseSymbol{Processor = processor}.Parse(typeof (string), TypedValue.Void, cell);
     Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
 }
コード例 #4
0
ファイル: ParseSymbolTest.cs プロジェクト: kpartusch/fitsharp
 private static void ParseCell(string cellContent, string symbolName)
 {
     var cell = new CellTreeLeaf(cellContent);
     var processor = Builder.CellProcessor();
     processor.Get<Symbols>().Save(symbolName, "value");
     new ParseSymbol{Processor = processor}.Parse(typeof (string), TypedValue.Void, cell);
     Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
 }
コード例 #5
0
ファイル: DeepCopyTest.cs プロジェクト: ChrisBDFA/fitsharp
 public void CopiesAttributes()
 {
     var source = new CellTreeLeaf("leaf");
     source.Value.SetAttribute(CellAttribute.Label, "mylabel");
     var result = copy.Make(source);
     source.Value.SetAttribute(CellAttribute.Label, "other");
     Assert.AreEqual("leaf,Label:mylabel[]", Write(result));
 }
コード例 #6
0
        [Test] public void ParseAddsInformationSuffix()
        {
            Parser.Processor.Get <Symbols>().Save("symbol", "value");

            var cell = new CellTreeLeaf("<<symbol");

            Parser.Parse(typeof(string), TypedValue.Void, cell);
            Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
        }
コード例 #7
0
ファイル: DeepCopyTest.cs プロジェクト: ChrisBDFA/fitsharp
 public void CopiesBranches()
 {
     var source = new CellTreeLeaf("root");
     source.AddBranchValue(new CellTreeLeaf("leafa"));
     source.AddBranchValue(new CellTreeLeaf("leafb"));
     var result = copy.Make(source);
     source.Branches[0].Add(new CellTreeLeaf("extra"));
     Assert.AreEqual("root[leafa[];leafb[]]", Write(result));
 }
コード例 #8
0
ファイル: DeepCopyTest.cs プロジェクト: PinetNicolas/fitsharp
        public void CopiesAttributes()
        {
            var source = new CellTreeLeaf("leaf");

            source.Value.SetAttribute(CellAttribute.Label, "mylabel");
            var result = copy.Make(source);

            source.Value.SetAttribute(CellAttribute.Label, "other");
            Assert.AreEqual("leaf,Label:mylabel[]", Write(result));
        }
コード例 #9
0
ファイル: DeepCopyTest.cs プロジェクト: ChrisBDFA/fitsharp
 public void DoesNotSubstituteWithinSubstitutes()
 {
     var source = new CellTreeLeaf("root");
     source.AddBranchValue(new CellTreeLeaf("leafa"));
     source.AddBranchValue(new CellTreeLeaf("leafb"));
     var result = copy.Make(source, original => original.Value != null && original.Value.Text == "leafa"
         ? new CellTree("new", "leafa")
         : null);
     source.Branches[0].Add(new CellTreeLeaf("extra"));
     Assert.AreEqual("root[null[new[];leafa[]];leafb[]]", Write(result));
 }
コード例 #10
0
ファイル: DeepCopyTest.cs プロジェクト: PinetNicolas/fitsharp
        public void CopiesBranches()
        {
            var source = new CellTreeLeaf("root");

            source.AddBranchValue(new CellTreeLeaf("leafa"));
            source.AddBranchValue(new CellTreeLeaf("leafb"));
            var result = copy.Make(source);

            source.Branches[0].Add(new CellTreeLeaf("extra"));
            Assert.AreEqual("root[leafa[];leafb[]]", Write(result));
        }
コード例 #11
0
        private static void ParseCell(string cellContent, string symbolName)
        {
            var cell      = new CellTreeLeaf(cellContent);
            var processor = Builder.CellProcessor();

            processor.Get <Symbols>().Save(symbolName, "value");
            new ParseSymbol {
                Processor = processor
            }.Parse(typeof(string), TypedValue.Void, cell);
            Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
        }
コード例 #12
0
 [Test] public void CachesParsedValue() {
     var cell = new CellTreeLeaf("<<symbol");
     var processor = Builder.CellProcessor();
     processor.Get<Symbols>().Save("symbol", "value");
     TypedValue result = processor.Parse(typeof (string), TypedValue.Void, cell);
     Assert.AreEqual("value", result.GetValue<string>());
     Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
     processor.Parse(typeof (string), TypedValue.Void, cell);
     Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
     Assert.AreEqual("value", result.GetValue<string>());
 }
コード例 #13
0
ファイル: DeepCopyTest.cs プロジェクト: PinetNicolas/fitsharp
        public void DoesNotSubstituteWithinSubstitutes()
        {
            var source = new CellTreeLeaf("root");

            source.AddBranchValue(new CellTreeLeaf("leafa"));
            source.AddBranchValue(new CellTreeLeaf("leafb"));
            var result = copy.Make(source, original => original.Value != null && original.Value.Text == "leafa"
                ? new CellTree("new", "leafa")
                : null);

            source.Branches[0].Add(new CellTreeLeaf("extra"));
            Assert.AreEqual("root[null[new[];leafa[]];leafb[]]", Write(result));
        }
コード例 #14
0
        [Test] public void CachesParsedValue()
        {
            var cell      = new CellTreeLeaf("<<symbol");
            var processor = new CellProcessorBase();

            processor.Store(new Symbol("symbol", "value"));
            TypedValue result = processor.Parse(typeof(string), TypedValue.Void, cell);

            Assert.AreEqual("value", result.GetValue <string>());
            Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
            processor.Parse(typeof(string), TypedValue.Void, cell);
            Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix));
            Assert.AreEqual("value", result.GetValue <string>());
        }
コード例 #15
0
        void SetUpSUT(string memberName)
        {
            this.memberName = memberName;
            testStatus = new TestStatus();
            processor = new Mock<CellProcessor>();
            invoke = new InvokeOperationDefault {Processor = processor.Object};
            check = new CheckOperationDefault {Processor = processor.Object};

            target = new TypedValue("target");
            result = new TypedValue("result");

            targetCell = new CellTreeLeaf("stuff");

            processor
                .Setup(p => p.Parse(typeof (MemberName), It.IsAny<TypedValue>(), It.Is<CellTreeLeaf>(c => c.Text == memberName)))
                .Returns(new TypedValue(new MemberName(memberName)));
            processor
                .Setup(p => p.Invoke(target, "member", It.Is<Tree<Cell>>(c => c.Branches.Count == 0)))
                .Returns(result);
            processor
                .Setup(p => p.Invoke(It.Is<TypedValue>(v => v.ValueString == "target"), "procedure", It.IsAny<Tree<Cell>>()))
                .Returns((TypedValue t, string s, Tree<Cell> c) => {
                    testStatus.Counts.AddCount(TestStatus.Right);
                    testStatus.LastAction = "blah blah";
                    return result;
                });
            processor.Setup(p => p.Compare(It.IsAny<TypedValue>(), It.IsAny<Tree<Cell>>())).Returns(true);
            processor.Setup(p => p.TestStatus).Returns(testStatus);
        }