mirror of
https://github.com/AlexMacocian/Sybil.git
synced 2026-07-15 15:19:59 +00:00
Stable implementation 0.1
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user