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


C# Mocks.CreateReactEnvironment方法代码示例

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


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

示例1: ExecuteWithLargerStackIfRequiredWithNoNewThread

		public void ExecuteWithLargerStackIfRequiredWithNoNewThread()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();

			environment.ExecuteWithLargerStackIfRequired<int>("foo");
			mocks.Engine.Verify(x => x.CallFunction<int>("foo"), Times.Exactly(1));
		}
开发者ID:jjridge7,项目名称:React.NET,代码行数:8,代码来源:ReactEnvironmentTest.cs

示例2: ExecuteWithLargerStackIfRequiredWithNoNewThread

		public void ExecuteWithLargerStackIfRequiredWithNoNewThread()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();

			environment.ExecuteWithLargerStackIfRequired<int>("1+1");
			mocks.Engine.Verify(x => x.Evaluate<int>("1+1"));
		}
开发者ID:prabirshrestha,项目名称:React.NET,代码行数:8,代码来源:ReactEnvironmentTest.cs

示例3: ShouldNotTransformJsxIfNoAnnotationPresent

		public void ShouldNotTransformJsxIfNoAnnotationPresent()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			var input = "<div>Hello World</div>";

			var output = environment.TransformJsx(input);
			Assert.Equal(input, output);
		}
开发者ID:prabirshrestha,项目名称:React.NET,代码行数:9,代码来源:ReactEnvironmentTest.cs

示例4: GeneratesContainerIdIfNotProvided

		public void GeneratesContainerIdIfNotProvided()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			mocks.Config.Setup(x => x.Scripts).Returns(new List<string>());

			var component1 = environment.CreateComponent("ComponentName", new { });
			var component2 = environment.CreateComponent("ComponentName", new { });
			Assert.AreEqual("react1", component1.ContainerId);
			Assert.AreEqual("react2", component2.ContainerId);
		}
开发者ID:ZeroarcSoftware,项目名称:React.NET,代码行数:11,代码来源:ReactEnvironmentTest.cs

示例5: ExecuteWithBabelShouldThrowIfBabelDisabled

		public void ExecuteWithBabelShouldThrowIfBabelDisabled()
		{
			var mocks = new Mocks();
			mocks.Config.Setup(x => x.LoadBabel).Returns(false);
			var environment = mocks.CreateReactEnvironment();

			Assert.Throws<BabelNotLoadedException>(() =>
			{
				environment.ExecuteWithBabel<string>("foobar");
			});
		}
开发者ID:joekrie,项目名称:React.NET,代码行数:11,代码来源:ReactEnvironmentTest.cs

示例6: ShouldTransformJsxIfAnnotationPresent

		public void ShouldTransformJsxIfAnnotationPresent()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();

			const string input = "/** @jsx React.DOM */ <div>Hello World</div>";
			environment.TransformJsx(input);

			mocks.Engine.Verify(x => x.Evaluate<string>(
				@"global.JSXTransformer.transform(""/** @jsx React.DOM */ <div>Hello World</div>"").code"
			));
		}
开发者ID:prabirshrestha,项目名称:React.NET,代码行数:12,代码来源:ReactEnvironmentTest.cs

示例7: ExecuteWithLargerStackIfRequiredShouldBubbleExceptions

		public void ExecuteWithLargerStackIfRequiredShouldBubbleExceptions()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			// Always fail
			mocks.Engine.Setup(x => x.CallFunction<int>("foobar"))
				.Throws(new Exception("Something bad happened :("));

			Assert.Throws<Exception>(() =>
			{
				environment.ExecuteWithLargerStackIfRequired<int>("foobar");
			});
		}
开发者ID:jjridge7,项目名称:React.NET,代码行数:13,代码来源:ReactEnvironmentTest.cs

示例8: ExecuteWithLargerStackIfRequiredWithNewThread

		public void ExecuteWithLargerStackIfRequiredWithNewThread()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			// Fail the first time Evaluate is called, succeed the second
			// http://stackoverflow.com/a/7045636
			mocks.Engine.Setup(x => x.CallFunction<int>("foo"))
				.Callback(() => mocks.Engine.Setup(x => x.CallFunction<int>("foo")))
				.Throws(new Exception("Out of stack space"));
				
			environment.ExecuteWithLargerStackIfRequired<int>("foo");
			mocks.EngineFactory.Verify(
				x => x.GetEngineForCurrentThread(It.IsAny<Action<IJsEngine>>()), 
				Times.Exactly(2),
				"Two engines should be created (initial thread and new thread)"
			);
			mocks.EngineFactory.Verify(
				x => x.DisposeEngineForCurrentThread(), 
				Times.Exactly(1),
				"Inner engine should be disposed"
			);
		}
开发者ID:jjridge7,项目名称:React.NET,代码行数:22,代码来源:ReactEnvironmentTest.cs

示例9: UsesProvidedContainerId

		public void UsesProvidedContainerId()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			mocks.Config.Setup(x => x.Scripts).Returns(new List<string>());

			var component1 = environment.CreateComponent("ComponentName", new { }, "foo");
			var component2 = environment.CreateComponent("ComponentName", new { });
			Assert.AreEqual("foo", component1.ContainerId);
			StringAssert.StartsWith("react_", component2.ContainerId);
		}
开发者ID:RichardD012,项目名称:React.NET,代码行数:11,代码来源:ReactEnvironmentTest.cs

示例10: ReturnsEngineToPool

		public void ReturnsEngineToPool()
		{
			var mocks = new Mocks();
			var environment = mocks.CreateReactEnvironment();
			mocks.Config.Setup(x => x.ReuseJavaScriptEngines).Returns(true);

			environment.CreateComponent("ComponentName", new { });
			mocks.EngineFactory.Verify(x => x.GetEngine(), Times.Once);
			environment.ReturnEngineToPool();

			environment.CreateComponent("ComponentName", new { });
			mocks.EngineFactory.Verify(x => x.GetEngine(), Times.AtLeast(2));
		}
开发者ID:RichardD012,项目名称:React.NET,代码行数:13,代码来源:ReactEnvironmentTest.cs


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