public void DefaultConstructor_Operations_AreNull() { BinaryOperatorResult result = new BinaryOperatorResult(); Assert.IsNull(result.TargetOperation); Assert.IsNull(result.ValueOperation); }
public void DefaultConstructor_TypeElement_IsEmpty() { BinaryOperatorResult result = new BinaryOperatorResult(); string type = result.Element.Element("Type").Value; Assert.AreEqual("", type); }
public void SetOperatorType_GenericOverload_SetTypeElement() { BinaryOperatorResult result = new BinaryOperatorResult(); result.SetOperatorType<AddOperator>(); string actual = result.Element.Element("Type").Value; Assert.AreEqual("Add", actual); }
public void GetOperator_TypeElementIsPresent_ReturnsLateBoundOperator() { XElement element = CreateBinaryOperatorResultXElement(); BinaryOperatorResult result = new BinaryOperatorResult(element); Operator op = result.GetOperator(null); Assert.IsNotNull(op); }
public void SetOperatorType_InvalidOperatorType_Throws() { BinaryOperatorResult result = new BinaryOperatorResult(); result.SetOperatorType(typeof(int)); }
public void GetOperator_TypeElementIsEmpty_Throws() { BinaryOperatorResult result = new BinaryOperatorResult(); result.GetOperator(null); }
public void ValueOperation_Set_ReplacesValueElementContent() { string expected = "some name"; XElement innerResult = CreatePatternResultXElement(expected); XElement element = CreateBinaryOperatorResultXElement(innerResult, innerResult); BinaryOperatorResult result = new BinaryOperatorResult(element); result.ValueOperation = new ConstantResult { Value = "4" }; XElement valueElement = element.Element("Value"); Assert.IsFalse(valueElement.Elements("PatternResult").Any()); Assert.AreEqual("4", valueElement.Element("ConstantResult").Value); }
public void ValueOperation_Get_ReadsTargetElement() { string expected = "some name"; XElement innerResult = CreatePatternResultXElement(expected); XElement element = CreateBinaryOperatorResultXElement(innerResult, innerResult); BinaryOperatorResult result = new BinaryOperatorResult(element); PatternResult operation = result.ValueOperation as PatternResult; Assert.IsNotNull(operation); Assert.AreEqual(expected, operation.Name); Assert.AreEqual(innerResult.ToString(), operation.Element.ToString()); }