示例#1
0
		protected override void Check()
		{
			var c1 = new C1();
			var c2 = new C2();
			var m = new Model();
			m.AddRootComponents(c1, c2);
			m.Seal();

			{
				var actual = (LtlFormula)(0 == c1.M(17) - 2);
				var expected = new StateFormula(
					new BinaryExpression(BinaryOperator.Equals,
						new IntegerLiteralExpression(0),
						new BinaryExpression(BinaryOperator.Subtract,
							new MethodInvocationExpression(
								m.Metadata.RootComponent.Subcomponents[0].ProvidedPorts[1],
								new ArgumentExpression(new IntegerLiteralExpression(17), RefKind.None)),
							new IntegerLiteralExpression(2))
						));

				Check(actual, expected);
			}

			{
				var actual = c1.F;
				var expected = new StateFormula(
					new BinaryExpression(BinaryOperator.Equals,
						new MethodInvocationExpression(m.Metadata.RootComponent.Subcomponents[0].ProvidedPorts[2]),
						new MethodInvocationExpression(m.Metadata.RootComponent.Subcomponents[0].ProvidedPorts[3],
							new ArgumentExpression(new IntegerLiteralExpression(1), RefKind.None),
							new ArgumentExpression(new BooleanLiteralExpression(true), RefKind.None))));

				Check(actual, expected);
			}

			{
				var actual = (LtlFormula)(c2.M3());
				var expected = new StateFormula(new MethodInvocationExpression(m.Metadata.RootComponent.Subcomponents[1].ProvidedPorts[6]));

				Check(actual, expected);
			}

			{
				var ic = c2;
				var actual = (LtlFormula)(ic.M3());
				var expected = new StateFormula(new MethodInvocationExpression(m.Metadata.RootComponent.Subcomponents[1].ProvidedPorts[6]));

				Check(actual, expected);
			}

			{
				var ic = c2;
				var actual = ((LtlFormula)(ic.M3())).Formula.InlineMethodInvocations();
				var expected = new StateFormula(new BooleanLiteralExpression(false));

				Check(actual, expected);
			}

			{
				var actual = (LtlFormula)(c2.M(1) == 1);
				var expected = new StateFormula(
					new BinaryExpression(BinaryOperator.Equals,
						new MethodInvocationExpression(m.Metadata.RootComponent.Subcomponents[1].ProvidedPorts[5],
							new ArgumentExpression(new IntegerLiteralExpression(1), RefKind.None)),
						new IntegerLiteralExpression(1)));

				Check(actual, expected);
			}

			Tests.Raises<InvalidOperationException>(() => ((LtlFormula)(c2.M4(111) == 81)).Formula.InlineMethodInvocations());
		}