Remove ApprovalTest and add TexttestFixture

This commit is contained in:
Samuel Dufour 2021-12-27 23:16:00 +01:00
parent 71fb9d59b1
commit 4746d897f5
4 changed files with 28 additions and 49 deletions

View File

@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<StartupObject>GildedRoseKata.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,27 +0,0 @@
using Xunit;
using System;
using System.IO;
using System.Text;
using ApprovalTests;
using ApprovalTests.Reporters;
using GildedRoseKata;
namespace GildedRoseTests
{
[UseReporter(typeof(DiffReporter))]
public class ApprovalTest
{
[Fact]
public void ThirtyDays()
{
var fakeoutput = new StringBuilder();
Console.SetOut(new StringWriter(fakeoutput));
Console.SetIn(new StringReader("a\n"));
Program.Main(new string[] { });
var output = fakeoutput.ToString();
Approvals.Verify(output);
}
}
}

View File

@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <OutputType>Exe</OutputType>
<IsPackable>false</IsPackable> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> <StartupObject>GildedRoseTests.TexttestFixture</StartupObject>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ApprovalTests" Version="5.7.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> <PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" /> </ItemGroup>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\GildedRose\GildedRose.csproj" /> <ProjectReference Include="..\GildedRose\GildedRose.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,12 @@
using System; 
using GildedRoseKata;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace GildedRoseKata namespace GildedRoseTests
{ {
public class Program public static class TexttestFixture
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
@ -33,14 +36,19 @@ namespace GildedRoseKata
SellIn = 5, SellIn = 5,
Quality = 49 Quality = 49
}, },
// this conjured item does not work properly yet // this conjured item does not work properly yet
new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
}; };
var app = new GildedRose(Items); var app = new GildedRose(Items);
int days = 2;
if (args.Length > 0)
{
days = int.Parse(args[0]) + 1;
}
for (var i = 0; i < 31; i++) for (var i = 0; i < days; i++)
{ {
Console.WriteLine("-------- day " + i + " --------"); Console.WriteLine("-------- day " + i + " --------");
Console.WriteLine("name, sellIn, quality"); Console.WriteLine("name, sellIn, quality");