Stable implementation 0.1

This commit is contained in:
2022-03-22 10:14:01 +01:00
parent ae34a4683d
commit bb536a88a3
15 changed files with 705 additions and 10 deletions
+67
View File
@@ -0,0 +1,67 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Sybil.IntegrationTests
{
[TestClass]
public sealed class FlowTests
{
private const string ExpectedNamespace =
@"namespace TestNamespace
{
using System;
public sealed class TestClass
{
TestClass(string fieldString) : base(fieldString)
{
this.fieldString = fieldString ?? throw new ArgumentNullException();
}
private string fieldString;
public string PropertyString { private set; get; }
public string GetFieldString()
{
return this.fieldString;
}
}
}";
[TestMethod]
public void NewNamespace_GeneratesExpected()
{
var namespaceSyntax = SyntaxBuilder.CreateNamespace("TestNamespace")
.WithUsing("System")
.WithClass(
SyntaxBuilder.CreateClass("TestClass")
.WithModifiers("public sealed")
.WithConstructor(
SyntaxBuilder.CreateConstructor("TestClass")
.WithBase(
SyntaxBuilder.CreateBaseConstructor()
.WithArgument("fieldString"))
.WithParameter("string", "fieldString")
.WithBody("this.fieldString = fieldString ?? throw new ArgumentNullException();"))
.WithField(
SyntaxBuilder.CreateField("string", "fieldString")
.WithModifier("private"))
.WithProperty(
SyntaxBuilder.CreateProperty("string", "PropertyString")
.WithModifier("public")
.WithAccessor(
SyntaxBuilder.CreateSetter()
.WithModifier("private"))
.WithAccessor(
SyntaxBuilder.CreateGetter()))
.WithMethod(
SyntaxBuilder.CreateMethod("string", "GetFieldString")
.WithModifier("public")
.WithBody("return this.fieldString;")))
.Build();
var namespaceString = namespaceSyntax.ToFullString();
namespaceString.Should().Be(ExpectedNamespace);
}
}
}
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sybil\Sybil.csproj" />
</ItemGroup>
</Project>