public OrchestrationTestHost AddTaskActivities(params Type[] taskActivityTypes) { foreach (Type type in taskActivityTypes) { ObjectCreator <TaskActivity> creator = new DefaultObjectCreator <TaskActivity>(type); activityObjectManager.Add(creator); } return(this); }
public OrchestrationTestHost AddTaskOrchestrations(params Type[] taskOrchestrationTypes) { foreach (Type type in taskOrchestrationTypes) { ObjectCreator <TaskOrchestration> creator = new DefaultObjectCreator <TaskOrchestration>(type); orchestrationObjectManager.Add(creator); } return(this); }
public OrchestrationTestHost AddTaskActivities(params TaskActivity[] taskActivityObjects) { foreach (TaskActivity instance in taskActivityObjects) { ObjectCreator <TaskActivity> creator = new DefaultObjectCreator <TaskActivity>(instance); activityObjectManager.Add(creator); } return(this); }
public DebugTestHost AddTaskOrchestrations(params Type[] taskOrchestrationTypes) { foreach (Type type in taskOrchestrationTypes) { ObjectCreator<TaskOrchestration> creator = new DefaultObjectCreator<TaskOrchestration>(type); this.orchestrationObjectManager.Add(creator); } return this; }
public void AddTypeToRepository() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(DateTime) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddType(typeof(DateTime)); var created = objectCreator.CreateObject(conditions, context); // Assert Assert.IsInstanceOf<DateTime>(created); }
public void AddParameterlessMethodToRepository() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(int) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddMethod(new Func<int>(() => { return 5; })); var created = objectCreator.CreateObject(conditions, context); // Assert Assert.AreEqual(5, created); }
public void AddAssemblyToRepository() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 3); var context = new ExpressionCreationContext { RequestedReturnType = typeof(GotoExpression) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddAssembly(typeof(GotoExpression).Assembly); // System.Core var created = objectCreator.CreateObject(conditions, context); // Assert Assert.IsInstanceOf<GotoExpression>(created); }
public void AddParameterMethodToRepository() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(long) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddMethod(new Func<DateTime, DateTime, long>((time1, time2) => { return time1.Ticks + time1.Ticks; })); objectCreator.TypeRepository.AddMethod(new Func<DateTime>(() => { return DateTime.Now; })); var created = objectCreator.CreateObject(conditions, context); // Assert Assert.IsInstanceOf<long>(created); }
public void CreateObjectWithNullConditions() { // Arrange var context = new ExpressionCreationContext { RequestedReturnType = typeof(long) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); objectCreator.TypeRepository.AddType(typeof(DateTime)); // Act & Assert Assert.Throws<ArgumentNullException>(() => { objectCreator.CreateObject(null, context); }); }
public void StopEvaluatingAppropriatelyWithContext() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 3); var context = new ExpressionCreationContext { RequestedReturnType = typeof(int) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddMethod(new Func<int, int, int>((int1, int2) => { return int1 + int2; })); objectCreator.TypeRepository.AddMethod(new Func<int>(() => { return 1; })); var created = objectCreator.CreateObject(conditions, context); // Assert // - - - - 4 - - - (Depth 1) // - - 2 - - - 2 - (Depth 2) // - 1 - 1 - 1 - 1 (Depth 3) Assert.AreEqual(4, created); }
public void RecoverFromThrownException() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(long) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddMethod(new Func<long>(() => { throw new InvalidOperationException(); })); // Should recover objectCreator.TypeRepository.AddMethod(new Func<long>(() => { return 10; })); var created = objectCreator.CreateObject(conditions, context); // Assert Assert.AreEqual(10, created); Assert.IsInstanceOf<Exception>(context.EvaluationExceptions[0]); }
public void NextTest() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 3); var context = new ExpressionCreationContext { RequestedReturnType = typeof(int) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act // Assert }
public void CreateTypeNullType() { // Arrange var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act & Assert Assert.Throws<ArgumentNullException>(() => { objectCreator.TypeRepository.AddType(null); }); }
public void CreateObjectWithoutSufficientTypes() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(int) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act objectCreator.TypeRepository.AddMethod(new Func<DateTime, int>((time) => { throw new InvalidOperationException(); })); var created = objectCreator.CreateObject(conditions, context); }
public void CreateObjectWithoutAnyTypes() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var context = new ExpressionCreationContext { RequestedReturnType = typeof(DateTime) }; var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); // Act & Assert Assert.Throws<ObjectCreationException>(() => { var created = objectCreator.CreateObject(conditions, context); }); }
public void CreateObjectWithNullContext() { // Arrange var conditions = new ExpressionCreationConditions(maxDepth: 10); var objectCreator = new DefaultObjectCreator(); objectCreator.TypeRepository = GetMockRepository(); objectCreator.TypeRepository.AddType(typeof(DateTime)); // Act Assert.Throws<ArgumentNullException>(() => { objectCreator.CreateObject(conditions, null); }); }