|
| 1 | +// ------------------------------------------------------------------------------------------------- |
| 2 | +// <copyright file="UmlCorePocoValidationGeneratorTestFixture.cs" company="Starion Group S.A."> |
| 3 | +// |
| 4 | +// Copyright 2022-2026 Starion Group S.A. |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// </copyright> |
| 19 | +// ------------------------------------------------------------------------------------------------ |
| 20 | + |
| 21 | +namespace SysML2.NET.CodeGenerator.Tests.Generators.UmlHandleBarsGenerators |
| 22 | +{ |
| 23 | + using System.IO; |
| 24 | + using System.Threading.Tasks; |
| 25 | + |
| 26 | + using NUnit.Framework; |
| 27 | + |
| 28 | + using SysML2.NET.CodeGenerator.Generators.UmlHandleBarsGenerators; |
| 29 | + |
| 30 | + [TestFixture] |
| 31 | + public class UmlCorePocoValidationGeneratorTestFixture |
| 32 | + { |
| 33 | + private DirectoryInfo outputDirectory; |
| 34 | + private UmlCorePocoValidationGenerator generator; |
| 35 | + |
| 36 | + [OneTimeSetUp] |
| 37 | + public void OneTimeSetup() |
| 38 | + { |
| 39 | + var directoryInfo = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); |
| 40 | + |
| 41 | + var path = Path.Combine("UML", "_SysML2.NET.AutoGenExtensions.ElementExtensions"); |
| 42 | + |
| 43 | + this.outputDirectory = directoryInfo.CreateSubdirectory(path); |
| 44 | + this.generator = new UmlCorePocoValidationGenerator(); |
| 45 | + } |
| 46 | + |
| 47 | + [Test] |
| 48 | + public async Task VerifyElementExtensionsAreGenerated() |
| 49 | + { |
| 50 | + await Assert.ThatAsync( |
| 51 | + () => this.generator.GenerateAsync(GeneratorSetupFixture.XmiReaderResult, this.outputDirectory), |
| 52 | + Throws.Nothing); |
| 53 | + } |
| 54 | + |
| 55 | + [Test] |
| 56 | + [Category("Expected")] |
| 57 | + public async Task VerifyExpectedElementExtensionsMatches() |
| 58 | + { |
| 59 | + var generatedCode = await this.generator.GenerateElementExtensions( |
| 60 | + GeneratorSetupFixture.XmiReaderResult, |
| 61 | + this.outputDirectory); |
| 62 | + |
| 63 | + var expected = await File.ReadAllTextAsync(Path.Combine(TestContext.CurrentContext.TestDirectory, |
| 64 | + "Expected/UML/Core/AutoGenExtensions/ElementExtensions.cs")); |
| 65 | + |
| 66 | + Assert.That(generatedCode, Is.EqualTo(expected)); |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments