private TestCaseSummary GetTestCaseSummary(Iteration iteration) { var testCases = _targetProcessFactory.GetTestCases(iteration); var passedCount = testCases.Count(tc => tc.LastStatus == "True"); var failedCount = testCases.Count(tc => tc.LastStatus == "False"); var notRunCount = testCases.Count(tc => tc.LastStatus == null); return new TestCaseSummary { PassedCount = passedCount, FailedCount = failedCount, NotRunCount = notRunCount }; }
public List<TestCase> GetTestCases(Iteration iteration) { var serializer = new JavaScriptSerializer(); var url = string.Format("http://creativeop.tpondemand.com/api/v1/Projects/2648/TestCases?where=UserStory.Iteration.Id eq '{0:d}'&include=[Name,LastStatus,LastRunDate]&take=10000", iteration.Id); var response = HttpUtilities.HttpGet(url); try { var testCases = serializer.Deserialize<ListResponse<TestCase>>(response); return testCases.Items; } catch { return new List<TestCase>(); } }
public List<UserStory> GetUserStoriesForCurrentIteration(Iteration iteration) { var serializer = new JavaScriptSerializer(); var url = string.Format("http://creativeop.tpondemand.com/api/v1/Iterations/{0:d}/UserStories/?take=10000&include=[Id,Name,EntityState[Id,Name]]", iteration.Id); var response = HttpUtilities.HttpGet(url); try { var tasks = serializer.Deserialize<ListResponse<UserStory>>(response); return tasks.Items; } catch { return new List<UserStory>(); } }
private List<TaskListItem> GetTaskList(Iteration iteration) { var report = new List<TaskListItem>(); var userStories = _targetProcessFactory.GetUserStoriesForCurrentIteration(iteration); foreach (var story in userStories) { report.Add(new TaskListItem { TaskId = story.Id, Name = story.Name, Status = GetTaskStatus(story.EntityState.Name) }); } return report; }
void TestIteration(Retrospective expected, Retrospective not, Iteration expectedIteration) { RetrospectiveFilter filter = new RetrospectiveFilter(); filter.Project.Add(SandboxProject); filter.Iteration.Add(expectedIteration); ResetInstance(); expectedIteration = (expectedIteration != null) ? Instance.Get.IterationByID(expectedIteration.ID) : null; expected = Instance.Get.RetrospectiveByID(expected.ID); not = Instance.Get.RetrospectiveByID(not.ID); ICollection<Retrospective> results = SandboxProject.GetRetrospectives(filter); Assert.IsTrue(FindRelated(expected, results), "Expected to find Retrospective that matched filter."); Assert.IsFalse(FindRelated(not, results), "Expected to NOT find Retrospective that doesn't match filter."); foreach (Retrospective result in results) Assert.AreEqual(expectedIteration, result.Iteration); }
public static ChartViewModel BuildBurndownChart(Iteration iteration, List<Assignable> tasks) { SeriesCollection sc; Series s; sc = new SeriesCollection(); s = new Series(); s.Name = "Effort"; s.Type = SeriesType.Bar; //s.DefaultElement.ShowValue = true; for (var day = iteration.StartDate.Date; day.Date <= iteration.EndDate.AddDays(1).Date; day = day.AddDays(1)) { var remainingTime = 0.0; //Do not show values for future dates. if (day <= DateTime.Today.AddDays(1)) { foreach (var task in tasks) { if (task.Times.Items.Count == 0) { remainingTime += task.Effort; } else { //NOTE: The Remain property on a Time object represents only the remaining time for that role (ie/ developer/qa) so we can't use it here. var timeSpent = task.Times.Items.Where(t => t.Date.Date < day).Sum(t => t.Spent); remainingTime += task.Effort - timeSpent; } } } s.AddElements(new Element(day.ToShortDateString(), remainingTime)); } sc.Add(s); var chart = InitializeBarGraph(sc, "Time Remaining"); return new ChartViewModel { ImageFileName = string.Format("{0:s}/{1:s}.png", chart.TempDirectory, chart.FileName) }; }
/// <summary> /// Initializes a new instance of the <see cref="RelationshipConfigurationViewModel"/> /// </summary> /// <param name="session">The current session</param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> used to navigate to details dialog of a <see cref="Thing"/> /// </param> /// <param name="iteration">The current iteration</param> /// <param name="action">The action to perform on update</param> /// <param name="settings">The module settings</param> /// <param name="source">The source <see cref="RelationshipConfiguration"/></param> /// <param name="sourceY">The <see cref="ClassKind"/> of source Y</param> /// <param name="sourceX">The <see cref="ClassKind"/> of source X</param> public RelationshipConfigurationViewModel(ISession session, IThingDialogNavigationService thingDialogNavigationService, Iteration iteration, Action action, RelationshipMatrixPluginSettings settings, RelationshipConfiguration source, ClassKind?sourceY, ClassKind?sourceX) : this(session, thingDialogNavigationService, iteration, action, settings) { this.PopulatePossibleRules(sourceY, sourceX); if (source.SelectedRule != null) { this.SelectedRule = this.PossibleRules.SingleOrDefault(x => x.Iid == source.SelectedRule); } }
public void SetUp() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.systemDomainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "System", ShortName = "SYS" }; this.siteDirectory.Domain.Add(this.systemDomainOfExpertise); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); var srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { Name = "testRDL", ShortName = "test" }; this.binaryRelationshipRule = new BinaryRelationshipRule(Guid.NewGuid(), this.cache, this.uri) { Name = "binary", ShortName = "binary" }; srdl.Rule.Add(this.binaryRelationshipRule); var mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = srdl }; mrdl.RequiredRdl = srdl; engineeringModelSetup.RequiredRdl.Add(mrdl); this.decompositionRule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri) { Name = "decomposition", ShortName = "decomposition" }; mrdl.Rule.Add(this.decompositionRule); this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.engineeringModel.EngineeringModelSetup = engineeringModelSetup; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.iteration.IterationSetup = this.iterationSetup; this.engineeringModel.Iteration.Add(iteration); this.ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri) { Owner = this.systemDomainOfExpertise }; iteration.RuleVerificationList.Add(this.ruleVerificationList); this.userRuleVerification = new UserRuleVerification(Guid.NewGuid(), this.cache, this.uri) { Rule = this.binaryRelationshipRule }; this.ruleVerificationList.RuleVerification.Add(this.userRuleVerification); this.cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration)); var chainOfRdls = new List <ReferenceDataLibrary>(); chainOfRdls.Add(mrdl); chainOfRdls.Add(srdl); this.session.Setup(x => x.GetEngineeringModelRdlChain(It.IsAny <EngineeringModel>())).Returns(chainOfRdls); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, null); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); }
public void SetUp() { this.session = new Mock <ISession>(); this.asembler = new Assembler(this.uri); this.cache = this.asembler.Cache; this.session.Setup(x => x.Assembler).Returns(this.asembler); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.elementDef1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); this.parameter1 = new Parameter(Guid.NewGuid(), this.cache, this.uri); this.valueSet1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri); this.valueSet2 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri); this.usage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri); this.parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri); this.parameterOverride.Parameter = this.parameter2; this.overrideValueset = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri); this.overrideValueset.ParameterValueSet = this.valueSet2; this.model.Iteration.Add(this.iteration); this.iteration.Element.Add(this.elementDef1); this.iteration.Element.Add(this.elementDef2); this.elementDef1.Parameter.Add(this.parameter1); this.parameter1.ValueSet.Add(this.valueSet1); this.usage.ElementDefinition = this.elementDef2; this.usage.ParameterOverride.Add(this.parameterOverride); this.parameterOverride.ValueSet.Add(this.overrideValueset); this.elementDef1.ContainedElement.Add(this.usage); this.sub1 = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); this.sub2 = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri); this.subValueset1 = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri); this.subValueset1.SubscribedValueSet = this.valueSet1; this.subValueset2 = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri); this.subValueset2.SubscribedValueSet = this.overrideValueset; this.sub1.ValueSet.Add(this.subValueset1); this.sub2.ValueSet.Add(this.subValueset2); this.parameter1.ParameterSubscription.Add(this.sub1); this.parameterOverride.ParameterSubscription.Add(this.sub2); this.cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model)); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.cache.TryAdd(new CacheKey(this.elementDef1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef1)); this.cache.TryAdd(new CacheKey(this.elementDef2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.elementDef2)); this.cache.TryAdd(new CacheKey(this.usage.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.usage)); this.cache.TryAdd(new CacheKey(this.parameter1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameter1)); this.cache.TryAdd(new CacheKey(this.parameter2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameter2)); this.cache.TryAdd(new CacheKey(this.valueSet1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.valueSet1)); this.cache.TryAdd(new CacheKey(this.valueSet2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.valueSet2)); this.cache.TryAdd(new CacheKey(this.parameterOverride.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterOverride)); this.cache.TryAdd(new CacheKey(this.overrideValueset.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.overrideValueset)); this.cache.TryAdd(new CacheKey(this.sub1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.sub1)); this.cache.TryAdd(new CacheKey(this.sub2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.sub2)); this.cache.TryAdd(new CacheKey(this.subValueset1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.subValueset1)); this.cache.TryAdd(new CacheKey(this.subValueset2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.subValueset2)); }
/// <summary> /// Query the required <see cref="ReferenceDataLibrary"/> for the <paramref name="iteration"/> /// </summary> /// <param name="transaction">The current transaction</param> /// <param name="iteration">The <see cref="Iteration"/></param> /// <returns>The <see cref="ReferenceDataLibrary"/></returns> public IEnumerable <ReferenceDataLibrary> QueryReferenceDataLibrary(NpgsqlTransaction transaction, Iteration iteration) { var engineeringModelSetup = this.EngineeringModelSetupDao.Read(transaction, typeof(SiteDirectory).Name).FirstOrDefault(ems => ems.IterationSetup.Contains(iteration.IterationSetup)); if (engineeringModelSetup == null) { throw new InvalidOperationException($"Could not find the associated engineering-modem-setup for iteration {iteration.Iid}"); } var mrdl = this.ModelReferenceDataLibraryDao.Read(transaction, typeof(SiteDirectory).Name, engineeringModelSetup.RequiredRdl).FirstOrDefault(); if (mrdl == null) { throw new InvalidOperationException($"Could not find the associated reference-data-library for iteration {iteration.Iid}"); } var list = new List <ReferenceDataLibrary> { mrdl }; list.AddRange(this.GetRequiredRdl(transaction, mrdl)); return(list); }
public void Setup() { this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.domain1 = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.cat1 = new Category(Guid.NewGuid(), this.cache, this.uri); this.cat1.PermissibleClass.Add(ClassKind.ElementUsage); this.cat2 = new Category(Guid.NewGuid(), this.cache, this.uri); this.siteDir.SiteReferenceDataLibrary.Add(this.srdl); this.siteDir.Model.Add(this.modelsetup); this.siteDir.Domain.Add(this.domain1); this.modelsetup.RequiredRdl.Add(this.mrdl); this.mrdl.DefinedCategory.Add(this.cat2); this.srdl.DefinedCategory.Add(this.cat1); this.modelsetup.ActiveDomain.Add(this.domain1); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.option = new Option(Guid.NewGuid(), this.cache, this.uri); this.definition1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); this.definition2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri); this.usage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.definition2 }; this.model.Iteration.Add(this.iteration); this.iteration.Option.Add(this.option); this.iteration.Element.Add(this.definition1); this.iteration.Element.Add(this.definition2); this.definition1.ContainedElement.Add(this.usage); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.cache.TryAdd(new CacheKey(this.definition1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.definition1)); this.cache.TryAdd(new CacheKey(this.usage.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.usage)); this.usageClone = this.usage.Clone(false); this.definition1Clone = this.definition1.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, this.definition1Clone); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); }
private static void WriteStoriesToStream(Iteration iteration, IEnumerable<Story> stories, StorySerializer serializer, FileStream tempFileStream) { int num; serializer.Iteration = iteration; var stream = serializer.Serialize(stories); var buffer = new byte[0x1000]; while ((num = stream.Read(buffer, 0, buffer.Length)) > 0) { tempFileStream.Write(buffer, 0, num); } }
/// <summary> /// Initializes a new instance of the <see cref="RelationshipConfigurationViewModel"/> /// </summary> /// <param name="session">The current session</param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> used to navigate to details dialog of a <see cref="Thing"/> /// </param> /// <param name="iteration">The current iteration</param> /// <param name="action">The action to perform on update</param> /// <param name="settings">The module settings</param> public RelationshipConfigurationViewModel(ISession session, IThingDialogNavigationService thingDialogNavigationService, Iteration iteration, Action action, RelationshipMatrixPluginSettings settings) : base(session, iteration, action, settings) { this.thingDialogNavigationService = thingDialogNavigationService; this.PossibleRules = new ReactiveList <BinaryRelationshipRule>(); this.WhenAnyValue(x => x.SelectedRule).Skip(1).Subscribe(_ => this.OnUpdateAction()); this.InitializeCommands(); }
private ChartViewModel GetBurndownChart(Iteration iteration) { var tasks = _targetProcessFactory.GetTasksForCurrentIteration(); return ChartService.BuildBurndownChart(iteration, tasks); }
public void Setup() { this.session = new Mock <ISession>(); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain" }; this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri); this.option = new Option(Guid.NewGuid(), this.cache, this.uri); this.elementDef = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.type1 = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "a" }; this.type2 = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri) { Name = "p" }; this.vs1 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Published = new ValueArray <string>(new List <string> { "1" }), Manual = new ValueArray <string>(new List <string> { "1" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.vs2 = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri) { Published = new ValueArray <string>(new List <string> { "1" }), Manual = new ValueArray <string>(new List <string> { "1" }), ValueSwitch = ParameterSwitchKind.MANUAL }; this.ovs1 = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri) { Published = new ValueArray <string>(new List <string> { "1" }), Manual = new ValueArray <string>(new List <string> { "1" }), ValueSwitch = ParameterSwitchKind.MANUAL, ParameterValueSet = this.vs1 }; this.gr = new ParameterGroup(Guid.NewGuid(), this.cache, this.uri) { Name = "gr" }; this.p1 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type1 }; this.p2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { ParameterType = this.type2 }; this.po1 = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Parameter = this.p1 }; this.p1.ValueSet.Add(this.vs1); this.p2.ValueSet.Add(this.vs2); this.po1.ValueSet.Add(this.ovs1); this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDef2, Owner = this.domain }; this.elementDef2.Parameter.Add(this.p1); this.elementDef2.Parameter.Add(this.p2); this.elementDef2.ParameterGroup.Add(this.gr); this.elementUsage.ParameterOverride.Add(this.po1); this.siteDir.Person.Add(this.person); this.siteDir.Model.Add(this.modelSetup); this.modelSetup.IterationSetup.Add(this.iterationSetup); this.modelSetup.Participant.Add(this.participant); this.participant.Person = this.person; this.model.Iteration.Add(this.iteration); this.model.EngineeringModelSetup = this.modelSetup; this.iteration.IterationSetup = this.iterationSetup; this.iteration.Option.Add(this.option); this.iteration.TopElement = this.elementDef; this.iteration.Element.Add(this.elementDef); this.iteration.Element.Add(this.elementDef2); this.elementDef.ContainedElement.Add(this.elementUsage); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }
public void Setup() { this.securityContext = new Mock <ISecurityContext>(); this.actualFiniteStateListService = new Mock <IActualFiniteStateListService>(); this.actualFiniteStateService = new Mock <IActualFiniteStateService>(); this.possibleFiniteStateListslService = new Mock <IPossibleFiniteStateListService>(); this.parameterValueSetService = new Mock <IParameterValueSetService>(); this.parameterOverrideValueSetService = new Mock <IParameterOverrideValueSetService>(); this.parameterService = new Mock <IParameterService>(); this.parameterOverrideService = new Mock <IParameterOverrideService>(); this.parameterSubscriptionService = new Mock <IParameterSubscriptionService>(); this.parameterSubscriptionValueSetService = new Mock <IParameterSubscriptionValueSetService>(); this.iterationService = new Mock <IIterationService>(); this.defaultValueArrayFactory = new Mock <IDefaultValueArrayFactory>(); this.compoundParameterTypeService = new Mock <ICompoundParameterTypeService>(); this.parameterUpdateService = new StateDependentParameterUpdateService(); this.finiteStateLogicService = new FiniteStateLogicService(); this.parameterUpdateService.ParameterValueSetService = this.parameterValueSetService.Object; this.parameterUpdateService.ParameterOverrideValueSetService = this.parameterOverrideValueSetService.Object; this.parameterUpdateService.ParameterService = this.parameterService.Object; this.parameterUpdateService.ParameterOverrideService = this.parameterOverrideService.Object; this.parameterUpdateService.ParameterSubscriptionService = this.parameterSubscriptionService.Object; this.parameterUpdateService.ParameterSubscriptionValueSetService = this.parameterSubscriptionValueSetService.Object; this.parameterUpdateService.CompoundParameterTypeService = this.compoundParameterTypeService.Object; this.iteration = new Iteration(Guid.NewGuid(), 1); this.option1 = new Option(Guid.NewGuid(), 1); this.iteration.Option.Add(new OrderedItem { K = 1, V = this.option1.Iid.ToString() }); this.psl1 = new PossibleFiniteStateList(Guid.NewGuid(), 1); this.psl2 = new PossibleFiniteStateList(Guid.NewGuid(), 1); this.ps11 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps12 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps21 = new PossibleFiniteState(Guid.NewGuid(), 1); this.ps22 = new PossibleFiniteState(Guid.NewGuid(), 1); this.asl1 = new ActualFiniteStateList(Guid.NewGuid(), 1); this.asl2 = new ActualFiniteStateList(Guid.NewGuid(), 1); this.iteration.PossibleFiniteStateList.Add(this.psl1.Iid); this.iteration.PossibleFiniteStateList.Add(this.psl2.Iid); this.iteration.ActualFiniteStateList.Add(this.asl1.Iid); this.iteration.ActualFiniteStateList.Add(this.asl2.Iid); this.psl1.PossibleState.Add(new OrderedItem { K = 1, V = this.ps11.Iid.ToString() }); this.psl1.PossibleState.Add(new OrderedItem { K = 2, V = this.ps12.Iid.ToString() }); this.psl2.PossibleState.Add(new OrderedItem { K = 1, V = this.ps21.Iid.ToString() }); this.psl2.PossibleState.Add(new OrderedItem { K = 2, V = this.ps22.Iid.ToString() }); this.asl1.PossibleFiniteStateList.Add(new OrderedItem { K = 1, V = this.psl1.Iid.ToString() }); this.asl1.PossibleFiniteStateList.Add(new OrderedItem { K = 2, V = this.psl2.Iid.ToString() }); // initializes actual states actual states this.as11 = new ActualFiniteState(Guid.NewGuid(), 1); this.as11.PossibleState.Add(this.ps11.Iid); this.as11.PossibleState.Add(this.ps21.Iid); this.as12 = new ActualFiniteState(Guid.NewGuid(), 1); this.as12.PossibleState.Add(this.ps11.Iid); this.as12.PossibleState.Add(this.ps22.Iid); this.asl1.ActualState.Add(this.as11.Iid); this.asl1.ActualState.Add(this.as12.Iid); this.asl2.PossibleFiniteStateList.Add(new OrderedItem { K = 1, V = this.psl2.Iid.ToString() }); this.as21 = new ActualFiniteState(Guid.NewGuid(), 1); this.as21.PossibleState.Add(this.ps21.Iid); this.as22 = new ActualFiniteState(Guid.NewGuid(), 1); this.as22.PossibleState.Add(this.ps22.Iid); this.asl2.ActualState.Add(this.as21.Iid); this.asl2.ActualState.Add(this.as22.Iid); this.possibleFiniteStateListslService.Setup( x => x.GetShallow(this.transaction, this.partition, It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)) .Returns(new List <Thing> { this.psl1, this.psl2 }); this.actualFiniteStateListService.Setup( x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.asl1, this.asl2 }); this.actualFiniteStateService.Setup( x => x.GetShallow(this.transaction, this.partition, It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)) .Returns(new List <Thing> { this.as11, this.as12 }); this.iterationService.Setup(x => x.GetActiveIteration(this.transaction, this.partition, this.securityContext.Object)) .Returns(this.iteration); this.parameter1 = new Parameter(Guid.NewGuid(), 1); this.parameter1.StateDependence = this.asl1.Iid; this.parameter2 = new Parameter(Guid.NewGuid(), 1); this.parameter2.StateDependence = this.asl1.Iid; this.parameter2.IsOptionDependent = true; this.parameterOverride1 = new ParameterOverride(Guid.NewGuid(), 1); this.parameterOverride1.Parameter = this.parameter1.Iid; this.parameterOverride2 = new ParameterOverride(Guid.NewGuid(), 1); this.parameterOverride2.Parameter = this.parameter2.Iid; this.parameterSubscription1 = new ParameterSubscription(Guid.NewGuid(), 1); this.parameterSubscription2 = new ParameterSubscription(Guid.NewGuid(), 1); this.parameter1.ParameterSubscription.Add(this.parameterSubscription1.Iid); this.parameterOverride2.ParameterSubscription.Add(this.parameterSubscription2.Iid); this.pvs11 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs12 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs21 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.pvs22 = new ParameterValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, }; this.povs11 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs12 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs21 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.povs22 = new ParameterOverrideValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), Computed = new ValueArray <string>(this.initValue), Reference = new ValueArray <string>(this.initValue), Published = new ValueArray <string>(this.initValue), Formula = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, ParameterValueSet = this.pvs11.Iid }; this.psvs11 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.pvs11.Iid }; this.psvs12 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.pvs12.Iid }; this.psvs21 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.povs21.Iid }; this.psvs22 = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1) { Manual = new ValueArray <string>(this.initValue), ValueSwitch = CDP4Common.EngineeringModelData.ParameterSwitchKind.REFERENCE, SubscribedValueSet = this.povs22.Iid }; this.parameter1.ValueSet.Add(this.pvs11.Iid); this.parameter1.ValueSet.Add(this.pvs12.Iid); this.parameter2.ValueSet.Add(this.pvs21.Iid); this.parameter2.ValueSet.Add(this.pvs22.Iid); this.parameterOverride1.ValueSet.Add(this.povs11.Iid); this.parameterOverride1.ValueSet.Add(this.povs12.Iid); this.parameterOverride2.ValueSet.Add(this.povs21.Iid); this.parameterOverride2.ValueSet.Add(this.povs22.Iid); this.parameterSubscription1.ValueSet.Add(this.psvs11.Iid); this.parameterSubscription1.ValueSet.Add(this.psvs12.Iid); this.parameterSubscription2.ValueSet.Add(this.psvs21.Iid); this.parameterSubscription2.ValueSet.Add(this.psvs22.Iid); this.parameterService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameter1, this.parameter2 }); this.parameterOverrideService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameterOverride1, this.parameterOverride2 }); this.parameterSubscriptionService.Setup(x => x.GetShallow(this.transaction, this.partition, null, this.securityContext.Object)) .Returns(new List <Thing> { this.parameterSubscription1, this.parameterSubscription2 }); this.parameterValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameter1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.pvs11, this.pvs12 }); this.parameterValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameter2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.pvs21, this.pvs22 }); this.parameterOverrideValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterOverride1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.povs11, this.povs12 }); this.parameterOverrideValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterOverride2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.povs21, this.povs22 }); this.parameterSubscriptionValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterSubscription1.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.psvs11, this.psvs12 }); this.parameterSubscriptionValueSetService.Setup( x => x.GetShallow(this.transaction, this.partition, this.parameterSubscription2.ValueSet, this.securityContext.Object)) .Returns(new List <Thing> { this.psvs21, this.psvs22 }); this.compoundParameterTypeService.Setup( x => x.GetShallow(this.transaction, this.partition, It.IsAny <IEnumerable <Guid> >(), this.securityContext.Object)) .Returns(new List <Thing>()); this.defaultValueArrayFactory.Setup(x => x.CreateDefaultValueArray(It.IsAny <Guid>())).Returns(new ValueArray <string>(new[] { "-" })); this.finiteStateLogicService.ActualFiniteStateListService = this.actualFiniteStateListService.Object; this.finiteStateLogicService.ActualFiniteStateService = this.actualFiniteStateService.Object; this.finiteStateLogicService.IterationService = this.iterationService.Object; this.finiteStateLogicService.PossibleFiniteStateListService = this.possibleFiniteStateListslService.Object; this.finiteStateLogicService.StateDependentParameterUpdateService = this.parameterUpdateService; this.sideEffect.FiniteStateLogicService = this.finiteStateLogicService; this.parameterUpdateService.DefaultValueSetFactory = this.defaultValueArrayFactory.Object; this.parameterValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterValueSet>(), It.IsAny <Parameter>())).Returns(true); this.parameterOverrideValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterOverrideValueSet>(), It.IsAny <ParameterOverride>())).Returns(true); this.parameterSubscriptionValueSetService.Setup(x => x.DeleteConcept(this.transaction, this.partition, It.IsAny <ParameterSubscriptionValueSet>(), It.IsAny <ParameterSubscription>())).Returns(true); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.permissionService = new Mock <IPermissionService>(); this.path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ReqIf", "testreq.reqif"); this.fileDialogService = new Mock <IOpenSaveFileDialogService>(); this.fileDialogService.Setup(x => x.GetOpenFileDialog(true, true, false, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), 1)).Returns(new string[] { this.path }); this.reqIf = new ReqIF { Lang = "en" }; this.reqIf.TheHeader = new ReqIFHeader() { Identifier = Guid.NewGuid().ToString() }; var corecontent = new ReqIFContent(); this.reqIf.CoreContent = corecontent; this.stringDatadef = new DatatypeDefinitionString(); this.spectype = new SpecificationType(); this.attribute = new AttributeDefinitionString() { DatatypeDefinition = this.stringDatadef }; this.spectype.SpecAttributes.Add(this.attribute); corecontent.DataTypes.Add(this.stringDatadef); this.settings = new RequirementsModuleSettings() { SavedConfigurations = { new ImportMappingConfiguration() { ReqIfId = this.reqIf.TheHeader.Identifier } } }; this.pluginSettingService = new Mock <IPluginSettingsService>(); this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(It.IsAny <bool>(), It.IsAny <JsonConverter[]>())).Returns(this.settings); this.pluginSettingService.Setup(x => x.Write(It.IsAny <PluginSettings>(), It.IsAny <JsonConverter[]>())); this.reqIfSerialiser = new Mock <IReqIFDeSerializer>(); this.reqIfSerialiser.Setup(x => x.Deserialize(It.IsAny <string>(), It.IsAny <bool>(), null)).Returns(new[] { this.reqIf }); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString()); this.assembler = new Assembler(this.uri); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri) { RequiredRdl = this.srdl }; this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.RequiredRdl.Add(this.mrdl); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationSetup = this.iterationSetup }; this.sitedir.Model.Add(this.modelsetup); this.modelsetup.IterationSetup.Add(this.iterationSetup); this.sitedir.Domain.Add(this.domain); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person }; this.sitedir.Person.Add(this.person); this.modelsetup.Participant.Add(this.participant); this.pt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl.ParameterType.Add(this.pt); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) } }); this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.serviceLocator = new Mock <IServiceLocator>(); this.serviceLocator.Setup(x => x.GetInstance <IPluginSettingsService>()).Returns(this.pluginSettingService.Object); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); var thingFactory = new ThingFactory(this.iteration, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap>(), new Dictionary <SpecType, SpecTypeMap>(), this.domain); this.dialog = new RequirementSpecificationMappingDialogViewModel(thingFactory, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.dialogNavigationService.Object, "EN", this.settings.SavedConfigurations[0] as ImportMappingConfiguration); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.uri = new Uri("http://www.rheagroup.com"); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.siteDirectory = new SiteDirectory(Guid.NewGuid(), null, this.uri) { Name = "TestSiteDir" }; var model1RDL = new ModelReferenceDataLibrary(Guid.NewGuid(), null, this.uri) { Name = "model1RDL" }; var model2RDL = new ModelReferenceDataLibrary(Guid.NewGuid(), null, this.uri) { Name = "model2RDL" }; this.model1 = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri) { Name = "model1" }; this.model1.RequiredRdl.Add(model1RDL); this.model2 = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri) { Name = "model2" }; this.model2.RequiredRdl.Add(model2RDL); this.iterationSetup11 = new IterationSetup(Guid.NewGuid(), null, this.uri); this.iterationSetup21 = new IterationSetup(Guid.NewGuid(), null, this.uri); this.iterationSetup11.IterationIid = Guid.NewGuid(); this.person = new Person(Guid.NewGuid(), null, this.uri) { GivenName = "testPerson" }; this.participant = new Participant(Guid.NewGuid(), null, this.uri) { Person = this.person, Domain = { this.domain } }; this.domain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri) { Name = "domaintest" }; this.person.DefaultDomain = this.domain; this.model1.Participant.Add(this.participant); this.model2.Participant.Add(this.participant); this.model1.IterationSetup.Add(this.iterationSetup11); this.model2.IterationSetup.Add(this.iterationSetup21); this.iterationSetup21.IterationIid = Guid.NewGuid(); this.siteDirectory.Model.Add(this.model1); this.siteDirectory.Model.Add(this.model2); this.siteDirectory.Person.Add(this.person); this.assembler = new Assembler(this.uri); var lazysiteDirectory = new Lazy <Thing>(() => this.siteDirectory); this.assembler.Cache.GetOrAdd(new CacheKey(lazysiteDirectory.Value.Iid, null), lazysiteDirectory); var iteration11 = new Iteration(Guid.NewGuid(), null, this.uri) { IterationSetup = this.iterationSetup11 }; var lazyiteration = new Lazy <Thing>(() => iteration11); this.assembler.Cache.GetOrAdd(new CacheKey(lazyiteration.Value.Iid, null), lazyiteration); this.iterationSetup11.IterationIid = iteration11.Iid; var lazyiterationSetup11 = new Lazy <Thing>(() => this.iterationSetup11); this.assembler.Cache.GetOrAdd(new CacheKey(lazyiterationSetup11.Value.Iid, null), lazyiterationSetup11); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >()); }
public void SetUp() { this.owner = new DomainOfExpertise(Guid.NewGuid(), null, null); this.owner.ShortName = "SYS"; this.owner.Name = "System"; this.otherOwner = new DomainOfExpertise(Guid.NewGuid(), null, null); this.otherOwner.ShortName = "THR"; this.otherOwner.Name = "Thermal"; // Reference SitedirectoryData var lengthunit = new SimpleUnit(Guid.NewGuid(), null, null); lengthunit.ShortName = "m"; lengthunit.Name = "metre"; var lengthscale = new RatioScale(Guid.NewGuid(), null, null); lengthscale.Unit = lengthunit; lengthscale.ShortName = "m-scale"; lengthscale.Name = "metre scale"; var xcoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "x", ShortName = "x" }; xcoord.PossibleScale.Add(lengthscale); xcoord.DefaultScale = lengthscale; var ycoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "y", ShortName = "y" }; ycoord.PossibleScale.Add(lengthscale); ycoord.DefaultScale = lengthscale; var zcoord = new SimpleQuantityKind(Guid.NewGuid(), null, null) { Name = "z", ShortName = "z" }; zcoord.PossibleScale.Add(lengthscale); zcoord.DefaultScale = lengthscale; var vector = new ArrayParameterType(Guid.NewGuid(), null, null); vector.Name = "coordinate"; vector.ShortName = "coord"; var xcomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = xcoord }; var ycomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = ycoord }; var zcomp = new ParameterTypeComponent(Guid.NewGuid(), null, null) { ParameterType = zcoord }; vector.Component.Add(xcomp); vector.Component.Add(ycomp); vector.Component.Add(zcomp); // iteration data this.iteration = new Iteration(Guid.NewGuid(), null, null); var optionA = new Option(Guid.NewGuid(), null, null) { Name = "Option A", ShortName = "OptionA" }; this.iteration.Option.Add(optionA); var optionB = new Option(Guid.NewGuid(), null, null) { Name = "Option B", ShortName = "OptionB" }; this.iteration.Option.Add(optionB); var possibleFiniteStateList = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleFiniteState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { ShortName = "state1", Name = "state 1" }; possibleFiniteStateList.PossibleState.Add(possibleFiniteState1); var possibleFiniteState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { ShortName = "state2", Name = "state 2" }; possibleFiniteStateList.PossibleState.Add(possibleFiniteState2); possibleFiniteStateList.DefaultState = possibleFiniteState1; var actualFiniteStateList = new ActualFiniteStateList(Guid.NewGuid(), null, null); actualFiniteStateList.PossibleFiniteStateList.Add(possibleFiniteStateList); var actualFiniteState1 = new ActualFiniteState(Guid.NewGuid(), null, null); actualFiniteState1.PossibleState.Add(possibleFiniteState1); actualFiniteStateList.ActualState.Add(actualFiniteState1); var actualFiniteState2 = new ActualFiniteState(Guid.NewGuid(), null, null); actualFiniteState2.PossibleState.Add(possibleFiniteState2); actualFiniteStateList.ActualState.Add(actualFiniteState2); var elementDefinitionA = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.owner, ShortName = "elementdefinitionA", Name = "element definition A" }; this.iteration.Element.Add(elementDefinitionA); var parameterA1 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = xcoord, Scale = lengthscale, Owner = this.owner }; var parameterValueSetA1 = new ParameterValueSet(Guid.NewGuid(), null, null); var valueArrayA = new ValueArray <string>(new List <string>() { "x" }); parameterValueSetA1.Manual = valueArrayA; parameterValueSetA1.Computed = valueArrayA; parameterValueSetA1.Reference = valueArrayA; parameterValueSetA1.Formula = valueArrayA; parameterA1.ValueSet.Add(parameterValueSetA1); elementDefinitionA.Parameter.Add(parameterA1); var parameterA2 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = vector, Owner = this.owner }; elementDefinitionA.Parameter.Add(parameterA2); var parameterValueSetA2 = new ParameterValueSet(Guid.NewGuid(), null, null); parameterA2.ValueSet.Add(parameterValueSetA2); var valueArrayA2 = new ValueArray <string>(new List <string>() { "x", "y", "z" }); parameterValueSetA2.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueSetA2.Manual = valueArrayA2; parameterValueSetA2.Computed = valueArrayA2; parameterValueSetA2.Reference = valueArrayA2; parameterValueSetA2.Formula = valueArrayA2; var parameterA3 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = xcoord, Scale = lengthscale, Owner = this.owner, IsOptionDependent = true, }; elementDefinitionA.Parameter.Add(parameterA3); var parameterValueSetA3OptionA = new ParameterValueSet(Guid.NewGuid(), null, null) { ActualOption = optionA }; var valueArrayA3OptionA = new ValueArray <string>(new List <string>() { "x" }); parameterValueSetA3OptionA.Manual = valueArrayA3OptionA; parameterValueSetA3OptionA.Reference = valueArrayA3OptionA; parameterValueSetA3OptionA.Computed = valueArrayA3OptionA; parameterValueSetA3OptionA.Formula = valueArrayA3OptionA; parameterA3.ValueSet.Add(parameterValueSetA3OptionA); var parameterValueSetA3OptionB = new ParameterValueSet(Guid.NewGuid(), null, null) { ActualOption = optionB }; var valueArrayA3OptionB = new ValueArray <string>(new List <string>() { "x" }); parameterValueSetA3OptionB.Manual = valueArrayA3OptionB; parameterValueSetA3OptionB.Reference = valueArrayA3OptionB; parameterValueSetA3OptionB.Computed = valueArrayA3OptionB; parameterValueSetA3OptionB.Formula = valueArrayA3OptionB; parameterA3.ValueSet.Add(parameterValueSetA3OptionB); var elementDefinitionB = new ElementDefinition(Guid.NewGuid(), null, null) { Owner = this.otherOwner, ShortName = "elementdefinitionB", Name = "element definition B" }; this.iteration.Element.Add(elementDefinitionB); var parameterB1 = new Parameter(Guid.NewGuid(), null, null) { ParameterType = xcoord, Owner = this.owner }; elementDefinitionB.Parameter.Add(parameterB1); // element usage var elementUsageOfA1 = new ElementUsage(Guid.NewGuid(), null, null) { ShortName = "usageofA1", Name = "usage of A 2", Owner = this.owner }; elementDefinitionB.ContainedElement.Add(elementUsageOfA1); elementUsageOfA1.ElementDefinition = elementDefinitionA; var elementUsageOfA2 = new ElementUsage(Guid.NewGuid(), null, null) { ShortName = "usageofA2", Name = "usage of A 2", Owner = this.owner }; elementDefinitionB.ContainedElement.Add(elementUsageOfA2); elementUsageOfA2.ElementDefinition = elementDefinitionA; var parameterOverrideA1 = new ParameterOverride() { Parameter = parameterA1, Container = elementUsageOfA2, Owner = this.owner }; parameterOverrideA1.Iid = Guid.NewGuid(); var parameterOverrideValueSetA1 = new ParameterOverrideValueSet(); parameterOverrideValueSetA1.Iid = Guid.NewGuid(); var overrideValueArrayA = new ValueArray <string>(new List <string>() { "x" }); parameterOverrideValueSetA1.Manual = overrideValueArrayA; parameterOverrideValueSetA1.Computed = overrideValueArrayA; parameterOverrideValueSetA1.Reference = overrideValueArrayA; parameterOverrideValueSetA1.Formula = overrideValueArrayA; parameterOverrideA1.ValueSet.Add(parameterOverrideValueSetA1); elementUsageOfA2.ParameterOverride.Add(parameterOverrideA1); var parameterOverrideA2 = new ParameterOverride() { Parameter = parameterA2, Container = elementUsageOfA2, Owner = this.owner }; parameterOverrideA2.Iid = Guid.NewGuid(); var parameterOverrideValueSetA2 = new ParameterOverrideValueSet(); parameterOverrideValueSetA2.Iid = Guid.NewGuid(); var overrideValueArrayA2 = new ValueArray <string>(new List <string>() { "x", "y", "z" }); parameterOverrideValueSetA2.Manual = overrideValueArrayA2; parameterOverrideValueSetA2.Computed = overrideValueArrayA2; parameterOverrideValueSetA2.Reference = overrideValueArrayA2; parameterOverrideValueSetA2.Formula = overrideValueArrayA2; parameterOverrideA2.ValueSet.Add(parameterOverrideValueSetA2); elementUsageOfA2.ParameterOverride.Add(parameterOverrideA2); var parameterOverrideA3 = new ParameterOverride() { Parameter = parameterA3, Container = elementUsageOfA2, Owner = this.owner }; parameterOverrideA3.Iid = Guid.NewGuid(); var parameterOverrideValueSetA3 = new ParameterOverrideValueSet(); parameterOverrideValueSetA3.Iid = Guid.NewGuid(); var parameterOverrideValueSetA3OptionA = new ParameterOverrideValueSet(); parameterOverrideValueSetA3OptionA.Iid = Guid.NewGuid(); parameterOverrideValueSetA3OptionA.ParameterValueSet = parameterValueSetA3OptionA; var overrideValueArrayA3OptionA = new ValueArray <string>(new List <string>() { "x" }); parameterOverrideValueSetA3OptionA.Manual = overrideValueArrayA3OptionA; parameterOverrideValueSetA3OptionA.Reference = overrideValueArrayA3OptionA; parameterOverrideValueSetA3OptionA.Computed = overrideValueArrayA3OptionA; parameterOverrideValueSetA3OptionA.Formula = overrideValueArrayA3OptionA; parameterOverrideA3.ValueSet.Add(parameterOverrideValueSetA3OptionA); var parameterOverrideValueSetA3OptionB = new ParameterOverrideValueSet(); parameterOverrideValueSetA3OptionB.Iid = Guid.NewGuid(); parameterOverrideValueSetA3OptionB.ParameterValueSet = parameterValueSetA3OptionB; var overrideValueArrayA3OptionB = new ValueArray <string>(new List <string>() { "x" }); parameterOverrideValueSetA3OptionB.Manual = overrideValueArrayA3OptionB; parameterOverrideValueSetA3OptionB.Reference = overrideValueArrayA3OptionB; parameterOverrideValueSetA3OptionB.Computed = overrideValueArrayA3OptionB; parameterOverrideValueSetA3OptionB.Formula = overrideValueArrayA3OptionB; parameterOverrideA3.ValueSet.Add(parameterOverrideValueSetA3OptionB); elementUsageOfA2.ParameterOverride.Add(parameterOverrideA3); }
private static Story CreateStory(V1Instance instance, string name, OmProject project, Iteration iteration, Member owner) { var story = instance.Create.Story(name, project); if (owner != null) { story.Owners.Add(owner); } story.Iteration = iteration; story.Save(); return(story); }
public static bool Active(this Iteration iteration) { return(DateTime.Now.Date >= iteration.Start.Date && DateTime.Now.Date <= iteration.End.Date); }
public async Task SetUp() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.assembler = new Assembler(this.uri); this.session = new Mock <ISession>(); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.outputTerminal = new OutputTerminal(); this.scriptViewModel = new Mock <IScriptPanelViewModel>(); this.scriptViewModel.SetupGet(x => x.OutputTerminal).Returns(() => this.outputTerminal); this.scriptViewModel.SetupProperty(x => x.SelectedSession, session.Object); this.scriptingProxy = new ScriptingProxy(this.thingDialogNavigationService.Object, this.panelNavigationService.Object, this.dialogNavigationService.Object); this.scriptingProxy.ScriptingPanelViewModel = this.scriptViewModel.Object; // Creation of the elements that can be searched using a script this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, null) { Name = "model", ShortName = "Train" }; this.engineerModel = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, null) { EngineeringModelSetup = engineeringModelSetup }; this.engineerModel.EngineeringModelSetup = this.engineeringModelSetup; this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, null) { IterationSetup = this.iterationSetup }; this.iteration.IterationSetup = this.iterationSetup; this.elementDefinition = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "element", ShortName = "Transformator" }; this.mass = new SimpleQuantityKind(Guid.NewGuid(), null, this.uri) { Name = "parameter", ShortName = "mass" }; this.parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, null) { ParameterType = this.mass }; this.parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, null) { Reference = new ValueArray <string>(new List <string> { "100" }), Computed = new ValueArray <string>(new List <string> { "-" }), Formula = new ValueArray <string>(new List <string> { "-" }), ValueSwitch = ParameterSwitchKind.REFERENCE }; this.engineerModel.Iteration.Add(this.iteration); this.iteration.Element.Add(this.elementDefinition); this.elementDefinition.Parameter.Add(this.parameter); this.parameter.ValueSet.Add(this.parameterValueSet); // Inclusion of the engineering model in the cache var testThing = new Lazy <Thing>(() => this.engineerModel); testThing.Value.Cache.TryAdd(new CacheKey(testThing.Value.Iid, null), testThing); }
public void Setup() { this.assembler = new Assembler(this.uri); RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); var person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "test" }; var participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = person, Domain = new List <DomainOfExpertise> { this.domain } }; this.session.Setup(x => x.ActivePerson).Returns(person); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "model" }; this.modelSetup.Participant.Add(participant); this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelSetup.IterationSetup.Add(this.iterationSetup); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "rs1", ShortName = "1" }; var tuple = new Tuple <DomainOfExpertise, Participant>(domain, participant); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, tuple } }); this.reqSpec.Owner = this.domain; this.iteration.RequirementsSpecification.Add(this.reqSpec); this.iteration.IterationSetup = this.iterationSetup; this.model.EngineeringModelSetup = this.modelSetup; this.model.Iteration.Add(this.iteration); this.grp1 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.grp11 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.grp2 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqSpec.Group.Add(this.grp1); this.reqSpec.Group.Add(this.grp2); this.grp1.Group.Add(this.grp11); this.req = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqSpec.Requirement.Add(this.req); this.requirementBrowserViewModel = new RequirementsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null); }
public void Process(Iteration iteration) { iteration.Population.Shuffle( ); }
public void IterationConstructorTest() { // Arrange var project = new ProjectMother().Build(); var expectedIterationName = "Test Iteration"; // Act var iteration = new Iteration(expectedIterationName, project); var actual = iteration.Name; var actualProject = iteration.Project; // Assert Assert.AreEqual(expectedIterationName, actual); Assert.AreEqual(project, actualProject); Assert.IsNotNull(iteration.GetDeliverables()); Assert.IsNotNull(iteration.GetAssignedMembers()); }
public void SetUp() { this.nestedElementTreeGenerator = new NestedElementTreeGenerator(); this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary <CDP4Common.Types.CacheKey, Lazy <Thing> >(); this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "SYS", Name = "System" }; this.domainOfExpertise_2 = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { ShortName = "TEST", Name = "Test" }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.option_A = new Option(Guid.NewGuid(), this.cache, this.uri) { ShortName = "OPT_A", Name = "Option A" }; this.option_B = new Option(Guid.NewGuid(), this.cache, this.uri) { ShortName = "OPT_B", Name = "Option B" }; this.elementDefinition_1 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Sat", Name = "Satellite" }; this.elementDefinition_2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { ShortName = "Bat", Name = "Battery" }; this.elementUsage_1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_a", Name = "battery a" }; this.elementUsage_2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri) { ElementDefinition = this.elementDefinition_2, ShortName = "bat_b", Name = "battery b" }; var simpleQuantityKind = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "m" }; var simpleQuantityKind2 = new SimpleQuantityKind(Guid.NewGuid(), null, null) { ShortName = "v" }; var actualList = new ActualFiniteStateList(Guid.NewGuid(), null, null); actualList.Owner = this.domainOfExpertise; var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), null, null); var possibleState1 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate1", ShortName = "1" }; var possibleState2 = new PossibleFiniteState(Guid.NewGuid(), null, null) { Name = "possiblestate2", ShortName = "2" }; possibleList1.PossibleState.Add(possibleState1); possibleList1.PossibleState.Add(possibleState2); actualList.PossibleFiniteStateList.Add(possibleList1); this.actualState_3 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_3.PossibleState.Add(possibleState1); this.actualState_4 = new ActualFiniteState(Guid.NewGuid(), this.cache, this.uri); this.actualState_4.PossibleState.Add(possibleState2); this.parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, ParameterType = simpleQuantityKind, IsOptionDependent = true }; this.parameter2 = new Parameter(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise_2, ParameterType = simpleQuantityKind2, StateDependence = actualList }; this.parameterOverride = new ParameterOverride(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domainOfExpertise, Parameter = this.parameter }; var parameterValueset_1 = new ParameterValueSet() { ActualOption = this.option_B, Iid = Guid.NewGuid() }; var parameterValueset_2 = new ParameterValueSet() { ActualOption = this.option_A, Iid = Guid.NewGuid() }; var parameterValueset_3 = new ParameterValueSet() { ActualState = this.actualState_3, Iid = Guid.NewGuid() }; var parameterValueset_4 = new ParameterValueSet() { ActualState = this.actualState_4, Iid = Guid.NewGuid() }; var values_1 = new List <string> { "2" }; var values_2 = new List <string> { "3" }; var values_3 = new List <string> { "220" }; var emptyValues = new List <string> { "-" }; var publishedValues = new List <string> { "123" }; var overrideValueset = new ParameterOverrideValueSet() { ParameterValueSet = parameterValueset_1, Iid = Guid.NewGuid() }; this.iteration.Option.Add(this.option_A); this.iteration.Option.Add(this.option_B); this.iteration.DefaultOption = this.option_A; parameterValueset_1.Manual = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Reference = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Computed = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Formula = new CDP4Common.Types.ValueArray <string>(values_1); parameterValueset_1.Published = new CDP4Common.Types.ValueArray <string>(publishedValues); parameterValueset_1.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_2.Manual = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Reference = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Computed = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Formula = new CDP4Common.Types.ValueArray <string>(values_2); parameterValueset_2.Published = new CDP4Common.Types.ValueArray <string>(publishedValues); parameterValueset_2.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_3.Manual = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Reference = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Computed = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Formula = new CDP4Common.Types.ValueArray <string>(values_3); parameterValueset_3.Published = new CDP4Common.Types.ValueArray <string>(emptyValues); parameterValueset_3.ValueSwitch = ParameterSwitchKind.MANUAL; parameterValueset_4.Manual = new CDP4Common.Types.ValueArray <string>(emptyValues); parameterValueset_4.Reference = new CDP4Common.Types.ValueArray <string>(emptyValues); parameterValueset_4.Computed = new CDP4Common.Types.ValueArray <string>(emptyValues); parameterValueset_4.Formula = new CDP4Common.Types.ValueArray <string>(emptyValues); parameterValueset_4.Published = new CDP4Common.Types.ValueArray <string>(publishedValues); parameterValueset_4.ValueSwitch = ParameterSwitchKind.MANUAL; overrideValueset.Manual = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Reference = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Computed = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Formula = new CDP4Common.Types.ValueArray <string>(values_1); overrideValueset.Published = new CDP4Common.Types.ValueArray <string>(publishedValues); overrideValueset.ValueSwitch = ParameterSwitchKind.MANUAL; this.parameter.ValueSet.Add(parameterValueset_1); this.parameter.ValueSet.Add(parameterValueset_2); this.parameterOverride.ValueSet.Add(overrideValueset); this.parameter2.ValueSet.Add(parameterValueset_3); this.parameter2.ValueSet.Add(parameterValueset_4); this.elementUsage_1.ExcludeOption.Add(this.option_A); this.elementUsage_1.ParameterOverride.Add(this.parameterOverride); this.elementDefinition_1.Parameter.Add(this.parameter); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_1); this.elementDefinition_1.ContainedElement.Add(this.elementUsage_2); this.elementDefinition_2.Parameter.Add(this.parameter); this.elementDefinition_2.Parameter.Add(this.parameter2); this.iteration.Element.Add(this.elementDefinition_1); this.iteration.Element.Add(this.elementDefinition_2); this.iteration.TopElement = this.elementDefinition_1; this.iteration.ActualFiniteStateList.Add(actualList); this.iteration.PossibleFiniteStateList.Add(possibleList1); actualList.ActualState.Add(this.actualState_3); actualList.ActualState.Add(this.actualState_4); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterSheetGenerator"/> class. /// </summary> /// <param name="session"> /// The <see cref="ISession"/> for which the parameter sheet is generated. /// </param> /// <param name="iteration"> /// The iteration that contains the <see cref="ParameterValueSet"/>s that will be generated on the Parameter sheet /// </param> /// <param name="participant"> /// The participant for which the sheet is generated. /// </param> public ParameterSheetGenerator(ISession session, Iteration iteration, Participant participant) { this.session = session; this.iteration = iteration; this.participant = participant; }
public Task <IList <WorkItem> > GetWorkItems(Project project, Iteration iteration) { throw new System.NotImplementedException(); }
/// <summary> /// 迭代 /// </summary> private void PerformIteration() { Iteration iteration = new Iteration(); iteration.Init(m_GSMContext); iteration.Run(); }
/// <summary> /// Read an <see cref="Iteration"/> from the underlying <see cref="IDal"/> and set the active <see cref="DomainOfExpertise"/> for the <see cref="Iteration"/>. /// </summary> /// <param name="iteration">The <see cref="Iteration"/> to read</param> /// <param name="domain">The active <see cref="DomainOfExpertise"/> for the <see cref="Iteration"/></param> /// <param name="activeMessageBus">Specify if the <see cref="CDPMessageBus"/> is used or not to notify listeners</param> /// <returns> /// an await-able <see cref="Task"/> /// </returns> /// <remarks> /// The Cache is updated with the returned objects and the <see cref="CDPMessageBus"/> /// is used or not to send messages to notify listeners of updates to the Cache /// </remarks> public async Task Read(Iteration iteration, DomainOfExpertise domain, bool activeMessageBus = true) { if (this.ActivePerson == null) { throw new InvalidOperationException("The Iteration cannot be read when the ActivePerson is null; The Open method must be called prior to any of the Read methods"); } // check if iteration is already open // if so check that the domain is not different var iterationDomainPair = this.openIterations.SingleOrDefault(x => x.Key.Iid == iteration.Iid); if (!iterationDomainPair.Equals(default(KeyValuePair <Iteration, Tuple <DomainOfExpertise, Participant> >))) { if (iterationDomainPair.Value.Item1 != domain) { throw new InvalidOperationException("The iteration is already open with another domain."); } } // Create the token source var cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenKey = Guid.NewGuid(); this.cancellationTokenSourceDictionary.TryAdd(cancellationTokenKey, cancellationTokenSource); IEnumerable <CDP4Common.DTO.Thing> dtoThings; try { var iterationDto = (CDP4Common.DTO.Iteration)iteration.ToDto(); this.Dal.Session = this; dtoThings = await this.Dal.Read(iterationDto, cancellationTokenSource.Token); cancellationTokenSource.Token.ThrowIfCancellationRequested(); } catch (OperationCanceledException) { logger.Info("Session.Read {0} {1} cancelled", iteration.ClassKind, iteration.Iid); return; } finally { this.cancellationTokenSourceDictionary.TryRemove(cancellationTokenKey, out cancellationTokenSource); } // proceed if no problem var enumerable = dtoThings as IList <CDP4Common.DTO.Thing> ?? dtoThings.ToList(); if (!enumerable.Any()) { logger.Warn("no data returned upon Read on {0}", this.DataSourceUri); } CDPMessageBus.Current.SendMessage(new SessionEvent(this, SessionStatus.BeginUpdate)); await this.Assembler.Synchronize(enumerable, activeMessageBus); this.AddIterationToOpenList(iteration.Iid, domain); CDPMessageBus.Current.SendMessage(new SessionEvent(this, SessionStatus.EndUpdate)); logger.Info("Synchronization with the {0} server done", this.DataSourceUri); }
public bool TryAddIteration(IterationModel model) { var iteration = new Iteration(model.Name, model.From, model.To, ProjectId, model.ReleaseId) { Description = model.Description }; if (Iterations.AnyOverlapsWith(iteration)) { Errors.Add(new Tuple<string, string>("from", "IterationOverlapedErrorKey")); Errors.Add(new Tuple<string, string>("to", "IterationOverlapedErrorKey")); return false; } Release release; if (!Releases.TryGetById(iteration.ReleaseId, out release)) throw new InvalidOperationException("iteration with id " + iteration.Id + "does not belong to any Release"); if (iteration.From < release.From || iteration.To > release.To) { Errors.Add(new Tuple<string, string>("from", "IterationOutsideTheBoundsOfRelease")); Errors.Add(new Tuple<string, string>("to", "IterationOutsideTheBoundsOfRelease")); return false; } Database.Iterations.Add(iteration); return true; }
public void Setup() { this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, null); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, null); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null) { RequiredRdl = this.srdl }; this.parameterType = new BooleanParameterType(Guid.NewGuid(), this.cache, null) { Name = "boolean", ShortName = "bool" }; this.category = new Category(Guid.NewGuid(), this.cache, null) { Name = "cat", ShortName = "cat", }; this.rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, null) { Category = this.category, ShortName = "rule", Name = "rule" }; this.rule.ParameterType.Add(this.parameterType); this.sitedir.Model.Add(this.modelsetup); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.modelsetup.RequiredRdl.Add(this.mrdl); this.srdl.ParameterType.Add(this.parameterType); this.srdl.DefinedCategory.Add(this.category); this.srdl.Rule.Add(this.rule); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, null) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, null) { IterationSetup = this.iterationsetup }; this.relation1 = new BinaryRelationship(Guid.NewGuid(), this.cache, null); this.relation2 = new BinaryRelationship(Guid.NewGuid(), this.cache, null); this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.cache, null) { Name = "spec1", ShortName = "spec1" }; this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, null) { Name = "spec2", ShortName = "spec2" }; this.gr1 = new RequirementsGroup(Guid.NewGuid(), this.cache, null) { Name = "gr1", ShortName = "gr1" }; this.gr2 = new RequirementsGroup(Guid.NewGuid(), this.cache, null) { Name = "gr2", ShortName = "gr2" }; this.req1 = new Requirement(Guid.NewGuid(), this.cache, null) { Name = "r1", ShortName = "r1" }; this.req2 = new Requirement(Guid.NewGuid(), this.cache, null) { Name = "r2", ShortName = "r2" }; this.def1 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { Name = "d1", ShortName = "d1" }; this.def2 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { Name = "d2", ShortName = "d2" }; this.model.Iteration.Add(this.iteration); this.iteration.Relationship.Add(this.relation1); this.iteration.Relationship.Add(this.relation2); this.iteration.RequirementsSpecification.Add(this.spec1); this.iteration.RequirementsSpecification.Add(this.spec2); this.spec1.Group.Add(this.gr1); this.spec1.Group.Add(this.gr2); this.spec1.Requirement.Add(this.req1); this.spec1.Requirement.Add(this.req2); this.iteration.Element.Add(this.def1); this.iteration.Element.Add(this.def2); this.relation1.Category.Add(this.category); this.relation2.Category.Add(this.category); this.spec1.Category.Add(this.category); this.spec2.Category.Add(this.category); this.req1.Category.Add(this.category); this.req2.Category.Add(this.category); this.gr1.Category.Add(this.category); this.gr2.Category.Add(this.category); this.def1.Category.Add(this.category); this.def2.Category.Add(this.category); this.relation1.ParameterValue.Add(new RelationshipParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.spec1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.req1.ParameterValue.Add(new SimpleParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.def1.Parameter.Add(new Parameter(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.gr1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); }