public void DefineImportWithScheduleElement() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock <IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny <GroupDefinition>(), It.IsAny <PluginFileInfo>())) .Callback <GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock <IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny <SerializableImportDefinition>(), It.IsAny <SerializableExportDefinition>())) .Returns(true); } Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func <IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); builder.RegisterObject(typeof(ImportOnProperty)); var registrator = builder.RegisterSchedule(); var vertex = registrator.AddInsertPoint(); registrator.LinkFromStart(vertex); registrator.LinkToEnd(vertex); registrator.Register(); var groupImportName = "groupImport"; builder.DefineImport(groupImportName, vertex); var groupName = "MyGroup"; builder.Register(groupName); Assert.IsNotNull(groupInfo); Assert.AreEqual(new GroupRegistrationId(groupName), groupInfo.GroupImports.First().ContainingGroup); Assert.AreEqual(vertex, groupInfo.GroupImports.First().ScheduleInsertPosition); Assert.IsFalse(groupInfo.GroupImports.First().ImportsToMatch.Any()); }
public void DefineSchedule() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock <IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny <GroupDefinition>(), It.IsAny <PluginFileInfo>())) .Callback <GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock <IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny <SerializableImportDefinition>(), It.IsAny <SerializableExportDefinition>())) .Returns(true); } Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func <IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); var actionInfo = builder.RegisterObject(typeof(ActionOnMethod)); var conditionInfo = builder.RegisterObject(typeof(ConditionOnProperty)); var registrator = builder.RegisterSchedule(); { var vertex = registrator.AddExecutingAction(actionInfo.RegisteredActions.First()); registrator.LinkFromStart(vertex, conditionInfo.RegisteredConditions.First()); registrator.LinkToEnd(vertex); registrator.Register(); } var groupName = "MyGroup"; builder.Register(groupName); Assert.AreEqual(actionInfo.RegisteredActions.First(), groupInfo.Schedule.Actions.First().Value); Assert.AreEqual(conditionInfo.RegisteredConditions.First(), groupInfo.Schedule.Conditions.First().Value); Assert.AreEqual(3, groupInfo.Schedule.Schedule.Vertices.Count()); }
public void DefineSchedule() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock<IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny<GroupDefinition>(), It.IsAny<PluginFileInfo>())) .Callback<GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock<IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny<SerializableImportDefinition>(), It.IsAny<SerializableExportDefinition>())) .Returns(true); } Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func<IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); var actionInfo = builder.RegisterObject(typeof(ActionOnMethod)); var conditionInfo = builder.RegisterObject(typeof(ConditionOnProperty)); var registrator = builder.RegisterSchedule(); { var vertex = registrator.AddExecutingAction(actionInfo.RegisteredActions.First()); registrator.LinkFromStart(vertex, conditionInfo.RegisteredConditions.First()); registrator.LinkToEnd(vertex); registrator.Register(); } var groupName = "MyGroup"; builder.Register(groupName); Assert.AreEqual(actionInfo.RegisteredActions.First(), groupInfo.Schedule.Actions.First().Value); Assert.AreEqual(conditionInfo.RegisteredConditions.First(), groupInfo.Schedule.Conditions.First().Value); Assert.AreEqual(3, groupInfo.Schedule.Schedule.Vertices.Count()); }
public void DefineImportWithScheduleElement() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock<IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny<GroupDefinition>(), It.IsAny<PluginFileInfo>())) .Callback<GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock<IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny<SerializableImportDefinition>(), It.IsAny<SerializableExportDefinition>())) .Returns(true); } Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func<IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); builder.RegisterObject(typeof(ImportOnProperty)); var registrator = builder.RegisterSchedule(); var vertex = registrator.AddInsertPoint(); registrator.LinkFromStart(vertex); registrator.LinkToEnd(vertex); registrator.Register(); var groupImportName = "groupImport"; builder.DefineImport(groupImportName, vertex); var groupName = "MyGroup"; builder.Register(groupName); Assert.IsNotNull(groupInfo); Assert.AreEqual(new GroupRegistrationId(groupName), groupInfo.GroupImports.First().ContainingGroup); Assert.AreEqual(vertex, groupInfo.GroupImports.First().ScheduleInsertPosition); Assert.IsFalse(groupInfo.GroupImports.First().ImportsToMatch.Any()); }
public void DefineExport() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock<IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny<GroupDefinition>(), It.IsAny<PluginFileInfo>())) .Callback<GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock<IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny<SerializableImportDefinition>(), It.IsAny<SerializableExportDefinition>())) .Returns(true); } Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func<IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); var firstInfo = builder.RegisterObject(typeof(ImportOnProperty)); var secondInfo = builder.RegisterObject(typeof(ExportOnProperty)); var thirdInfo = builder.RegisterObject(typeof(ActionOnMethod)); var fourthInfo = builder.RegisterObject(typeof(ConditionOnProperty)); builder.Connect(firstInfo.RegisteredImports.First(), secondInfo.RegisteredExports.First()); var registrator = builder.RegisterSchedule(); { var vertex = registrator.AddExecutingAction(thirdInfo.RegisteredActions.First()); registrator.LinkFromStart(vertex, fourthInfo.RegisteredConditions.First()); registrator.LinkToEnd(vertex); registrator.Register(); } var groupExportName = "groupExport"; builder.DefineExport(groupExportName); var groupName = "MyGroup"; builder.Register(groupName); Assert.IsNotNull(groupInfo); Assert.AreEqual(new GroupRegistrationId(groupName), groupInfo.GroupExport.ContainingGroup); Assert.AreEqual(groupExportName, groupInfo.GroupExport.ContractName); Assert.That( groupInfo.GroupExport.ProvidedExports, Is.EquivalentTo( new List<ExportRegistrationId> { firstInfo.RegisteredExports.First(), thirdInfo.RegisteredExports.First(), fourthInfo.RegisteredExports.First(), })); }
public void DefineExport() { var plugins = CreatePluginTypes(); GroupDefinition groupInfo = null; var repository = new Mock <IPluginRepository>(); { repository.Setup(r => r.Parts()) .Returns(plugins); repository.Setup(r => r.AddGroup(It.IsAny <GroupDefinition>(), It.IsAny <PluginFileInfo>())) .Callback <GroupDefinition, PluginFileInfo>((g, f) => groupInfo = g); } var importEngine = new Mock <IConnectParts>(); { importEngine.Setup(i => i.Accepts(It.IsAny <SerializableImportDefinition>(), It.IsAny <SerializableExportDefinition>())) .Returns(true); } Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); Func <IBuildFixedSchedules> scheduleBuilder = () => new FixedScheduleBuilder(); var builder = new GroupDefinitionBuilder( repository.Object, importEngine.Object, identityGenerator, scheduleBuilder, new PluginFileInfo("a", DateTimeOffset.Now)); var firstInfo = builder.RegisterObject(typeof(ImportOnProperty)); var secondInfo = builder.RegisterObject(typeof(ExportOnProperty)); var thirdInfo = builder.RegisterObject(typeof(ActionOnMethod)); var fourthInfo = builder.RegisterObject(typeof(ConditionOnProperty)); builder.Connect(firstInfo.RegisteredImports.First(), secondInfo.RegisteredExports.First()); var registrator = builder.RegisterSchedule(); { var vertex = registrator.AddExecutingAction(thirdInfo.RegisteredActions.First()); registrator.LinkFromStart(vertex, fourthInfo.RegisteredConditions.First()); registrator.LinkToEnd(vertex); registrator.Register(); } var groupExportName = "groupExport"; builder.DefineExport(groupExportName); var groupName = "MyGroup"; builder.Register(groupName); Assert.IsNotNull(groupInfo); Assert.AreEqual(new GroupRegistrationId(groupName), groupInfo.GroupExport.ContainingGroup); Assert.AreEqual(groupExportName, groupInfo.GroupExport.ContractName); Assert.That( groupInfo.GroupExport.ProvidedExports, Is.EquivalentTo( new List <ExportRegistrationId> { firstInfo.RegisteredExports.First(), thirdInfo.RegisteredExports.First(), fourthInfo.RegisteredExports.First(), })); }