-
Notifications
You must be signed in to change notification settings - Fork 0
Fix #7 : Export to excel for selected TaggedValue #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
antoineatstariongroup
merged 14 commits into
development
from
feat/GH7-generic-export-to-excel
Dec 9, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f814bbe
Fix #7 : Export to excel for selected TaggedValue
antoineatstariongroup 3f8727e
Fix some codesmells
antoineatstariongroup 00e2b0c
refactor base values assignment
antoineatstariongroup 72023b9
Added test for ExcelWriter
antoineatstariongroup 7d33494
Fix code smell for ICacheService
antoineatstariongroup 314d399
ExcelWriter code smell
antoineatstariongroup a5a8f17
Async code smell
antoineatstariongroup e566941
fix previous code smells
antoineatstariongroup bfb11ff
code smùell
antoineatstariongroup 6316021
Requested changes
antoineatstariongroup dc68b3d
Alexander's comment
antoineatstariongroup 063a426
fix code smell for App.cs
antoineatstariongroup 87ab6f9
AssemblyLocation set a readonly
antoineatstariongroup cae7ef5
Fix worksheet name issue and added Stereotype/type values on SlimElement
antoineatstariongroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
EA-ModelKit.Tests/Converters/BooleanToVisibilityConverterTestFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // ----------------------------------------------------------------------------------- | ||
| // <copyright file="BooleanToVisibilityConverterTestFixture.cs" company="Starion Nederland B.V."> | ||
| // Copyright (c) 2024 Starion Nederland B.V. | ||
| // | ||
| // Authors: Alex Vorobiev, Antoine Théate, Sam Gerené, Anh-Toan Bui Long | ||
| // | ||
| // This file is part of ESA SysML plugin for Enterprise Architect | ||
| // European Space Agency Community License – v2.4 Permissive (Type 3) | ||
| // See LICENSE file for details | ||
| // | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------------------- | ||
|
|
||
| namespace EAModelKit.Tests.Converters | ||
| { | ||
| using System.Globalization; | ||
| using System.Windows; | ||
|
|
||
| using EAModelKit.Converters; | ||
|
|
||
| using NUnit.Framework; | ||
|
|
||
| [TestFixture] | ||
| public class BooleanToVisibilityConverterTestFixture | ||
| { | ||
| private BooleanToVisibilityConverter converter; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| this.converter = new BooleanToVisibilityConverter(); | ||
| } | ||
|
|
||
| [Test] | ||
| public void VerifyConvert() | ||
| { | ||
| Assert.Multiple(() => | ||
| { | ||
| Assert.That(this.converter.Convert(null, typeof(Visibility), "", CultureInfo.InvariantCulture), Is.EqualTo(Visibility.Collapsed)); | ||
| Assert.That(this.converter.Convert(true, typeof(Visibility), "", CultureInfo.InvariantCulture), Is.EqualTo(Visibility.Visible)); | ||
| Assert.That(this.converter.Convert(false, typeof(Visibility), "", CultureInfo.InvariantCulture), Is.EqualTo(Visibility.Collapsed)); | ||
| Assert.That(this.converter.Convert(false, typeof(Visibility), "Invert", CultureInfo.InvariantCulture), Is.EqualTo(Visibility.Visible)); | ||
| Assert.That(this.converter.Convert(true, typeof(Visibility), "Invert", CultureInfo.InvariantCulture), Is.EqualTo(Visibility.Collapsed)); | ||
| Assert.That(() => this.converter.ConvertBack(Visibility.Collapsed, typeof(bool), "", CultureInfo.InvariantCulture), Throws.Exception); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
45 changes: 45 additions & 0 deletions
45
EA-ModelKit.Tests/Converters/StringCollectionConverterTestFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // ----------------------------------------------------------------------------------- | ||
| // <copyright file="FileImportExportCollectionConverterTestFixture.cs" company="Starion Nederland B.V."> | ||
| // Copyright (c) 2024 Starion Nederland B.V. | ||
| // | ||
| // Authors: Alex Vorobiev, Antoine Théate, Sam Gerené, Anh-Toan Bui Long | ||
| // | ||
| // This file is part of ESA SysML plugin for Enterprise Architect | ||
| // European Space Agency Community License – v2.4 Permissive (Type 3) | ||
| // See LICENSE file for details | ||
| // | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------------------- | ||
|
|
||
| namespace EAModelKit.Tests.Converters | ||
| { | ||
| using System.Globalization; | ||
|
|
||
| using EAModelKit.Converters; | ||
|
|
||
| using NUnit.Framework; | ||
|
|
||
| [TestFixture] | ||
| public class StringCollectionConverterTestFixture | ||
| { | ||
| private StringCollectionConverter converter; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| this.converter = new StringCollectionConverter(); | ||
| } | ||
|
|
||
| [Test] | ||
| public void VerifyConvert() | ||
| { | ||
| Assert.That(this.converter.Convert(null, typeof(IEnumerable<string>), null, CultureInfo.InvariantCulture), Is.EquivalentTo(new List<string>())); | ||
| } | ||
|
|
||
| [Test] | ||
| public void VerifyConvertBack() | ||
| { | ||
| Assert.That(this.converter.ConvertBack(null, typeof(IEnumerable<string>), null, CultureInfo.InvariantCulture), Is.Empty); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // <copyright file="TestSlimElement.cs" company="Starion Group S.A."> | ||
| // | ||
| // Copyright (C) 2024 Starion Group S.A. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------------------------------- | ||
|
|
||
| namespace EAModelKit.Tests.Helpers | ||
| { | ||
| using EA; | ||
|
|
||
| using EAModelKit.Model.Slims; | ||
|
|
||
| using Moq; | ||
|
|
||
| /// <summary> | ||
| /// <see cref="TestSlimElement"/> is a <see cref="SlimElement"/> that is used for test purpose | ||
| /// </summary> | ||
| internal class TestSlimElement: SlimElement | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="TestSlimElement" /> | ||
| /// </summary> | ||
| /// <param name="element">The associated <see cref="Element"/></param> | ||
| /// <param name="taggedValues">The associated collection of <see cref="SlimTaggedValue"/></param> | ||
| public TestSlimElement(Element element, IReadOnlyList<SlimTaggedValue> taggedValues) : base(element, taggedValues) | ||
| { | ||
| } | ||
|
|
||
| public TestSlimElement(string kind, string name, string alias, string notes, IReadOnlyList<SlimTaggedValue> taggedValues): | ||
| this(CreateElement(kind, name, alias, notes), taggedValues) | ||
| { | ||
| } | ||
|
|
||
| private static Element CreateElement(string kind, string name, string alias, string notes) | ||
| { | ||
| var element = new Mock<Element>(); | ||
| element.Setup(x => x.Name).Returns(name); | ||
| element.Setup(x => x.Alias).Returns(alias); | ||
| element.Setup(x => x.Notes).Returns(notes); | ||
| element.Setup(x => x.Stereotype).Returns(kind); | ||
| return element.Object; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0" encoding="UTF-16" standalone="no"?> | ||
| <EADATA exporter="Enterprise Architect" version="1.0"> | ||
| <Dataset_0> | ||
| <Data> | ||
| <Row> | ||
| <Object_ID>20</Object_ID> | ||
| <Property>"ABC"</Property> | ||
| <Value>""</Value> | ||
| </Row> | ||
| <Row> | ||
| <Object_ID>20</Object_ID> | ||
| <Property>"CDF"</Property> | ||
| <Value>"15"</Value> | ||
| </Row> | ||
| <Row> | ||
| <Object_ID>26</Object_ID> | ||
| <Property>"CDF"</Property> | ||
| <Value>"16"</Value> | ||
| </Row> | ||
| <Row> | ||
| <Object_ID>10</Object_ID> | ||
| <Property>"CDF"</Property> | ||
| <Value>"17"</Value> | ||
| </Row> | ||
| </Data> | ||
| </Dataset_0> | ||
| </EADATA> |
69 changes: 69 additions & 0 deletions
69
EA-ModelKit.Tests/Services/Cache/CacheServiceTestFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // <copyright file="CacheServiceTestFixture.cs" company="Starion Group S.A."> | ||
| // | ||
| // Copyright (C) 2024 Starion Group S.A. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------------------------------- | ||
|
|
||
| namespace EAModelKit.Tests.Services.Cache | ||
| { | ||
| using EA; | ||
|
|
||
| using EAModelKit.Services.Cache; | ||
|
|
||
| using Moq; | ||
|
|
||
| using NUnit.Framework; | ||
|
|
||
| using File = System.IO.File; | ||
|
|
||
| [TestFixture] | ||
| public class CacheServiceTestFixture | ||
| { | ||
| private CacheService cacheService; | ||
| private Mock<Repository> repository; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| this.cacheService = new CacheService(); | ||
| this.repository = new Mock<Repository>(); | ||
| this.cacheService.Initialize(this.repository.Object); | ||
|
|
||
| this.repository.Setup(x => x.SQLQuery(It.Is<string>(i => i.Contains("t_objectproperties")))) | ||
| .Returns(QueryResourceContent("TaggedValues.xml")); | ||
| } | ||
|
|
||
| [Test] | ||
| public void VerifyGetTaggedValues() | ||
| { | ||
| Assert.Multiple(() => | ||
| { | ||
| Assert.That(this.cacheService.GetTaggedValues(10).Count, Is.EqualTo(1)); | ||
| Assert.That(this.cacheService.GetTaggedValues(20).Count, Is.EqualTo(2)); | ||
| Assert.That(this.cacheService.GetTaggedValues(26).Count, Is.EqualTo(1)); | ||
| Assert.That(this.cacheService.GetTaggedValues(27).Count, Is.EqualTo(0)); | ||
| Assert.That(this.cacheService.GetTaggedValues([10,20,26]).Count, Is.EqualTo(4)); | ||
| }); | ||
| } | ||
|
|
||
| private static string QueryResourceContent(string fileName) | ||
| { | ||
| var path = Path.Combine(Directory.GetCurrentDirectory(), "Resources", "CacheService", fileName); | ||
| return File.ReadAllText(path); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add newline at the end of each file. We had this rule earlier and it got removed. There is good reason to make diffs more readible when using git and git extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new line is already present on each file, just the Tests.csproj one that missed it