当前位置: 首页>>代码示例>>C#>>正文


C# Formula.Equals方法代码示例

本文整理汇总了C#中SpreadsheetUtilities.Formula.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Formula.Equals方法的具体用法?C# Formula.Equals怎么用?C# Formula.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpreadsheetUtilities.Formula的用法示例。


在下文中一共展示了Formula.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEqualsWithNormalizer

 public void TestEqualsWithNormalizer()
 {
     Formula a = new Formula("x1 + x2", VarToUpper, IsValid);
     Formula b = new Formula("X1 + X2");
     Assert.AreEqual(true, a.Equals(b));
     Assert.AreEqual(true, b.Equals(a));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:7,代码来源:FormulaUnitTest1.cs

示例2: TestEqualsFromToString

 public void TestEqualsFromToString()
 {
     string expression = "x + 2";
     Formula a = new Formula(expression);
     Formula b = new Formula(a.ToString());
     Assert.AreEqual(true, a.Equals(b));
     Assert.AreEqual(true, b.Equals(a));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:8,代码来源:FormulaUnitTest1.cs

示例3: EqualsTest2

 public void EqualsTest2()
 {
     Formula f1 = new Formula("2+3");
     Formula f2 = new Formula("2+4");
     Assert.IsFalse(f1.Equals(f2));
 }
开发者ID:jiiehe,项目名称:cs3500,代码行数:6,代码来源:FormulaTest.cs

示例4: EqualsOnNegativeScientificNotation

 public void EqualsOnNegativeScientificNotation()
 {
     Formula f = new Formula("5e-4");
     Formula g = new Formula("0.0005");
     Assert.IsTrue(f.Equals(g));
 }
开发者ID:drewmacmac,项目名称:old_class,代码行数:6,代码来源:UnitTest1.cs

示例5: EqualsTest

 public void EqualsTest()
 {
     Formula f1 = new Formula("2+3");
     Formula f2 = new Formula("2+3");
     Assert.IsTrue(f1.Equals(f2));
 }
开发者ID:jiiehe,项目名称:cs3500,代码行数:6,代码来源:FormulaTest.cs

示例6: TestEquals

 public void TestEquals()
 {
     Formula one = new Formula("x1+y2", Normalize, Validate);
     Assert.IsTrue(one.Equals(new Formula("X1+Y2")));
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:5,代码来源:FormulaTester.cs

示例7: TestEquals3

 public void TestEquals3()
 {
     Formula three = new Formula("x1+y2");
     Assert.IsFalse(three.Equals(new Formula("y2+x1")));
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:5,代码来源:FormulaTester.cs

示例8: Test35

 public void Test35()
 {
     Formula f1 = new Formula("2+X1*3.00");
     Formula f2 = new Formula("2.00+X1*3.0");
     Assert.IsTrue(f1.Equals(f2));
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:6,代码来源:GradingTests.cs

示例9: Test37

 public void Test37()
 {
     Formula f = new Formula("2");
     Assert.IsFalse(f.Equals(null));
     Assert.IsFalse(f.Equals(""));
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:6,代码来源:GradingTests.cs

示例10: SetCellContents

        /// <summary>
        /// If the formula parameter is null, throws an ArgumentNullException.
        /// 
        /// Otherwise, if name is null or invalid, throws an InvalidNameException.
        /// 
        /// Otherwise, if changing the contents of the named cell to be the formula would cause a 
        /// circular dependency, throws a CircularException.  (No change is made to the spreadsheet.)
        /// 
        /// Otherwise, the contents of the named cell becomes formula.  The method returns a
        /// Set consisting of name plus the names of all other cells whose value depends,
        /// directly or indirectly, on the named cell.
        /// 
        /// For example, if name is A1, B1 contains A1*2, and C1 contains B1+A1, the
        /// set {A1, B1, C1} is returned.
        /// </summary>
        protected override ISet<string> SetCellContents(string name, Formula formula)
        {
            // If the formula parameter is null, throws an ArgumentNullException.
            if (formula.Equals(null))
            {
                throw new ArgumentNullException();
            }

            // Otherwise, if name is null or invalid, throws an InvalidNameException.
            if (!Cell.validName(name) || !IsValid(name))
            {
                throw new InvalidNameException();
            }

            // If cell doesn't exist, add it
            if (!allCells.ContainsKey(name))
            {
                // add new cell
                allCells.Add(name, new Cell(name, formula, Lookup));
                // if formula contained variables, setup new dependencies
                if (formula.GetVariables().Count() > 0)
                {
                    foreach (string str in formula.GetVariables())
                    {
                        graph.AddDependency(name, str);
                    }
                }
                HashSet<string> dependents = new HashSet<string>();
                List<string> dependentCells = GetCellsToRecalculate(name).ToList();

                dependents.Add(name);
                foreach (string str in dependentCells)
                {
                    allCells[str].eval(Lookup);
                    dependents.Add(str);
                }
                return dependents;

            }

            // Otherwise, if changing the contents of the named cell to be the formula would cause a 
            // circular dependency, throws a CircularException.  (No change is made to the spreadsheet.)
            GetCellsToRecalculate(name);

            // Otherwise, the contents of the named cell becomes formula.
            // If cell exists, overwrite it's content
            Cell temp;
            if (allCells.TryGetValue(name, out temp))
            {
                temp.setContents(formula);
                
            }

            // If the replacement formula has variables, replace the dependency of the old cell with 
            // new ones from the new formula.
            if (formula.GetVariables().Count() > 0)
            {
                List<string> variables = new List<string>();
                foreach (string str in formula.GetVariables())
                {
                    variables.Add(str);
                }
                graph.ReplaceDependents(name, variables);
            }

            // Get all dependents, indirect and direct, and then add them to a List which is then
            // added to the returned HashSet
            HashSet<string> dependent = new HashSet<string>();
            List<string> dependentCell = GetCellsToRecalculate(name).ToList();
            dependent.Add(name);
            foreach (string str in dependentCell)
            {
                allCells[str].eval(Lookup);
                dependent.Add(str);
            }
            return dependent;
        }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:92,代码来源:spreadsheet.cs

示例11: TestEqualsSameObjectType

 public void TestEqualsSameObjectType()
 {
     Formula testFormula1 = new Formula("a/b");
     Formula testFormula2 = new Formula("a/b");
     Assert.IsTrue(testFormula1.Equals(testFormula2));
 }
开发者ID:Buck417,项目名称:First-Half-CS-3500,代码行数:6,代码来源:UnitTest1.cs

示例12: TestNotEqualsSameResult

 public void TestNotEqualsSameResult()
 {
     Formula a = new Formula("2 + 3 + 1");
     Formula b = new Formula("5 + 1");
     Assert.AreEqual(false, a.Equals(b));
     Assert.AreEqual(false, b.Equals(a));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:7,代码来源:FormulaUnitTest1.cs

示例13: TestEqualsNotAnObject

 public void TestEqualsNotAnObject()
 {
     Formula f = new Formula("2 + 3");
     Assert.AreEqual(false, f.Equals(new Object()));
     Assert.AreEqual(false, f.Equals("Hi there"));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:6,代码来源:FormulaUnitTest1.cs

示例14: TestNotEqualsReversedExpressions

 public void TestNotEqualsReversedExpressions()
 {
     Formula a = new Formula("a + b");
     Formula b = new Formula("b + a");
     Assert.AreEqual(false, a.Equals(b));
     Assert.AreEqual(false, b.Equals(a));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:7,代码来源:FormulaUnitTest1.cs

示例15: TestEqualsWithPrecision

 public void TestEqualsWithPrecision() {
     Formula a = new Formula("2.0");
     Formula b = new Formula("2.0000");
     Assert.AreEqual(true, a.Equals(b));
     Assert.AreEqual(true, b.Equals(a));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:6,代码来源:FormulaUnitTest1.cs


注:本文中的SpreadsheetUtilities.Formula.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。