Пример #1
0
        public void Name_Get_ReadsNameElement()
        {
            string expected = "Hi!";
            XElement element = CreateOffsetXElement(expected);
            OffsetElement offset = new OffsetElement(element);

            Assert.AreEqual(expected, offset.Name);
        }
Пример #2
0
        public void RootOperation_Get_NoOperationsElementAndNoNamedPattern_ReturnNull()
        {
            XElement element = CreateOffsetXElement("OffsetName");
            XElement root = CreateRootXElement(element);
            OffsetElement offset = new OffsetElement(element);

            var operation = offset.RootOperation;

            Assert.IsNull(operation);
        }
Пример #3
0
        public void Name_Set_SetsNameElement()
        {
            string expected = "Hi!";

            OffsetElement offset = new OffsetElement
            {
                Name = expected
            };

            string actual = offset.Element.Element("Name").Value;
            Assert.AreEqual(expected, actual);
        }
Пример #4
0
 private IntPtr CalculateOffset(OffsetElement offsetElement)
 {
     string result = offsetElement.RootOperation.Execute(_context);
     IntPtr address = new IntPtr(Convert.ToInt64(result, 0x10));
     return address;
 }
Пример #5
0
        public void RootOperation_Get_NoOperationsElement_ReturnNamedPatternOperation()
        {
            XElement element = CreateOffsetXElement("OffsetName");
            XElement pattern = CreatePatternXElement("OffsetName");
            XElement root = CreateRootXElement(pattern, element);
            OffsetElement offset = new OffsetElement(element);

            var operation = offset.RootOperation;
            var patternResult = operation as PatternResult;
            PatternResult_Accessor accessor = new PatternResult_Accessor(new PrivateObject(patternResult));
            Assert.IsNotNull(operation);
            Assert.AreEqual("OffsetName", patternResult.Name);
            Assert.AreEqual(pattern, accessor.PatternElement.Element);
        }
Пример #6
0
        public void DefaultConstructor_Name_IsEmpty()
        {
            OffsetElement offset = new OffsetElement();

            Assert.AreEqual("", offset.Name);
        }
Пример #7
0
        public void RootOperation_Set_SetsOperationsElement()
        {
            string expected = "C";
            OffsetElement offset = new OffsetElement
            {
                RootOperation = new ConstantResult { Value = expected }
            };

            XElement constantResult = offset.Element.Element("Operations").Element("ConstantResult");

            Assert.AreEqual(expected, constantResult.Value);
        }
Пример #8
0
        public void RootOperation_Set_ReplacesInnerResultElement()
        {
            string expected = "C";
            XElement innerResult = CreateConstantResultXElement("45");
            XElement operationsElement = new XElement("Operations", innerResult);
            XElement element = CreateOffsetXElement("OffsetName", operationsElement);
            OffsetElement offset = new OffsetElement(element);
            offset.RootOperation = new ConstantResult { Value = expected };

            XElement constantResult = offset.Element.Element("Operations").Element("ConstantResult");

            Assert.AreEqual(expected, constantResult.Value);
            Assert.IsNull(innerResult.Parent);
        }
Пример #9
0
        public void RootOperation_SetNull_RemovesOperationsElement()
        {
            XElement operations = CreateOperationsXElementWithConstantResult();
            XElement element = CreateOffsetXElement("OffsetName", operations);
            OffsetElement offset = new OffsetElement(element);

            offset.RootOperation = null;

            Assert.IsFalse(element.Elements("Operations").Any());
        }