8a6c31e795a1 — MiyamotoAkira tip 10 months ago
All the changes to the code have been done.

There are still things that could be done.
M src/GildedRose.Console/GildedRose.Console.csproj +4 -0
@@ 4,6 4,10 @@ 
     <ProjectReference Include="..\GildedRose.FSharp.Library\GildedRose.FSharp.Library.fsproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <PackageReference Include="FSharp.Core" Version="5.0.0" />
+  </ItemGroup>
+
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>net5.0</TargetFramework>

          
M src/GildedRose.Console/Program.cs +40 -53
@@ 1,35 1,28 @@ 
 using System.Collections.Generic;
 using System.Linq;
 using GildedRose.FSharp.Library;
+using Microsoft.FSharp.Collections;
 
 namespace GildedRose.Console
 {
     public class Program
     {
-        public const string Brie = "Aged Brie";
-        public const string Vest = "+5 Dexterity Vest";
-        public const string Elixir = "Elixir of the Mongoose";
-        public const string Sulfuras = "Sulfuras, Hand of Ragnaros";
-        public const string Backstage = "Backstage passes to a TAFKAL80ETC concert";
-        public const string ConjuredCake = "Conjured Mana Cake";
-
-        public IList<Data.Item> Items;
+        public FSharpList<Data.Item> Items;
         static void Main(string[] args)
         {
             System.Console.WriteLine("OMGHAI!");
 
             var app = new Program()
             {
-                Items = new List<Data.Item>
+                Items = ListModule.OfSeq(new List<Data.Item>
                 {
-                    new Data.Item(Vest, 10, 20),
-                    new Data.Item (Brie, 2, 0),
-                    new Data.Item  (Elixir, 5, 7),
-                    new Data.Item (Sulfuras, 0, 80),
-                    new Data.Item (Backstage, 15, 20),
-                    new Data.Item (ConjuredCake, 3, 6)
-                }
-
+                    new Data.Item(Data.Vest, 10, 20),
+                    new Data.Item(Data.Brie, 2, 0),
+                    new Data.Item(Data.Elixir, 5, 7),
+                    new Data.Item(Data.Sulfuras, 0, 80),
+                    new Data.Item(Data.Backstage, 15, 20),
+                    new Data.Item(Data.ConjuredCake, 3, 6)
+                })
             };
 
             app.UpdateQuality();

          
@@ 40,33 33,29 @@ namespace GildedRose.Console
 
         public void UpdateQuality()
         {
-            Items.ToList().ForEach(item => {
-                UpdateQualityBeforeSellIn(item);;
-                UpdateSellIn(item);
-                UpdateQualityAfterSellIn(item);
-            });
+            Items = Data.updateQuality(Items);
         }
 
-        private void UpdateQualityBeforeSellIn(Data.Item item)
+        private Data.Item UpdateQualityBeforeSellIn(Data.Item item)
         {
             switch (item.Name)
             {
-                case Brie:
+                case Data.Brie:
                     if (item.Quality < 50)
                     {
-                        item.Quality = item.Quality + 1;
+                        item = Data.changeQuality(item, 1);
                     }
-                    return;
-                case Backstage:
+                    return item;
+                case Data.Backstage:
                     if (item.Quality < 50)
                     {
-                        item.Quality = item.Quality + 1;
+                        item = Data.changeQuality(item, 1);
 
                         if (item.SellIn < 11)
                         {
                             if (item.Quality < 50)
                             {
-                                item.Quality = item.Quality + 1;
+                                item = Data.changeQuality(item, 1);
                             }
                         }
 

          
@@ 74,58 63,56 @@ namespace GildedRose.Console
                         {
                             if (item.Quality < 50)
                             {
-                                item.Quality = item.Quality + 1;
+                                item = Data.changeQuality(item, 1);
                             }
                         }
                         
                     }
-                    return;
-                case Sulfuras:
-                    return;
+                    return item;
+                case Data.Sulfuras:
+                    return item;
                 default:
                     if (item.Quality > 0)
-                        item.Quality = item.Quality - 1;
-                    return;
+                        item = Data.changeQuality(item, -1);
+                    return item;
             }
         }
 
-        private void UpdateQualityAfterSellIn(Data.Item item)
+        private Data.Item UpdateQualityAfterSellIn(Data.Item item)
         {
-            if (item.SellIn >= 0) return;
+            if (item.SellIn >= 0) return item;
 
             switch (item.Name)
             {
-                case Brie:
+                case Data.Brie:
                     if (item.Quality < 50)
                     {
-                        item.Quality = item.Quality + 1;
+                        item = Data.changeQuality(item, 1);
                     }
-                    return;
-                case Sulfuras:
-                    return;
-                case Backstage:
-                    item.Quality = item.Quality - item.Quality;
-                    return;
+                    return item;
+                case Data.Sulfuras:
+                    return item;
+                case Data.Backstage:
+                        item = Data.changeQuality(item, -item.Quality);
+                    return item;
                 default:
                     if (item.Quality > 0)
                     {
-                        item.Quality = item.Quality - 1;
+                        item = Data.changeQuality(item, -1);
                     }
-                    return;
+                    return item;
             }
         }
         
-        private void UpdateSellIn(Data.Item item)
+        private Data.Item UpdateSellIn(Data.Item item)
         {
             switch (item.Name)
             {
-                case Sulfuras:
-                    break;
+                case Data.Sulfuras:
+                    return item;
                 default:
-                    item.SellIn = item.SellIn -1;
-                    break;
+                    return Data.reduceSellIn(item);
             }
         }
     }
-
 }

          
A => src/GildedRose.FSharp.Console/GildedRose.FSharp.Console.fsproj +16 -0
@@ 0,0 1,16 @@ 
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net5.0</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Compile Include="Program.fs" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\GildedRose.FSharp.Library\GildedRose.FSharp.Library.fsproj" />
+  </ItemGroup>
+
+</Project>

          
A => src/GildedRose.FSharp.Console/Program.fs +18 -0
@@ 0,0 1,18 @@ 
+// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp
+
+open System
+open GildedRose.FSharp.Library
+
+[<EntryPoint>]
+let main argv =
+    printfn "We are starting"
+    let items = Data.updateQuality [{Name = Data.Vest; SellIn = 10; Quality = 20}
+                                    {Name = Data.Brie; SellIn = 2; Quality = 0}
+                                    {Name = Data.Elixir; SellIn = 5; Quality = 7}
+                                    {Name = Data.Sulfuras; SellIn = 0; Quality = 80}
+                                    {Name = Data.Backstage; SellIn = 15; Quality = 20}
+                                    {Name = Data.ConjuredCake; SellIn = 3; Quality = 6}]
+    printfn "%A" items
+    
+    Console.ReadKey() |> ignore
+    0 // return an integer exit code

          
M src/GildedRose.FSharp.Library/Library.fs +75 -3
@@ 1,7 1,79 @@ 
 namespace GildedRose.FSharp.Library
 
 module Data =
+    [<Literal>]
+    let Brie = "Aged Brie"
+    [<Literal>]
+    let Vest = "+5 Dexterity Vest"
+    [<Literal>]
+    let Elixir = "Elixir of the Mongoose"
+    [<Literal>]
+    let Sulfuras = "Sulfuras, Hand of Ragnaros"
+    [<Literal>]
+    let Backstage = "Backstage passes to a TAFKAL80ETC concert"
+    [<Literal>]
+    let ConjuredCake = "Conjured Mana Cake"
+
     type Item =
-        { mutable Name : string
-          mutable SellIn : int
-          mutable Quality : int}
+        {  Name : string
+           SellIn : int
+           Quality : int}
+
+    let changeQuality item amount =
+        { item with Quality = item.Quality + amount }
+
+    let reduceSellIn item =
+        { item with SellIn = item.SellIn - 1 }
+
+    let updateSellIn item =
+        match item.Name with
+        | Sulfuras -> item
+        | _ -> reduceSellIn item
+
+    let updateQualityBeforeSellIn item =
+        match item.Name with
+        | Brie ->
+            if item.Quality < 50
+            then changeQuality item 1
+            else item
+        | Backstage ->
+            if item.Quality < 50
+            then
+                changeQuality item 1
+                |> fun x ->
+                        if x.SellIn < 11 && x.Quality < 50
+                        then changeQuality x 1
+                        else x
+                |> fun x ->
+                        if x.SellIn < 6 && x.Quality < 50
+                        then changeQuality x 1
+                        else x
+            else item
+        | Sulfuras -> item
+        | _ ->
+            if item.Quality > 0
+            then changeQuality item -1
+            else item
+
+    let updateQualityAfterSellIn item =
+        if item.SellIn >= 0
+        then item
+        else
+            match item.Name with
+            | Brie ->
+                if item.Quality < 50
+                then changeQuality item 1
+                else item
+            | Sulfuras -> item
+            | Backstage -> changeQuality item -item.Quality
+            | _ ->
+                if item.Quality > 0
+                then changeQuality item -1
+                else item
+
+    let updateQuality items =
+        // items
+        // |> List.map updateQualityBeforeSellIn
+        // |> List.map updateSellIn
+        // |> List.map updateQualityAfterSellIn
+        items |> List.map (updateQualityBeforeSellIn >> updateSellIn >> updateQualityAfterSellIn)

          
M tests/GildedRose.FSharp.Tests/Tests.fs +61 -75
@@ 3,145 3,131 @@ namespace GildedRose.Tests
 open System
 open Xunit
 
-open GildedRose.Console
 open GildedRose.FSharp.Library.Data
 
 module Tests =
 
-    let findItemByName (app: Program) name =
-        app.Items |> Seq.toList |> List.find (fun x -> x.Name = name)
+    let findItemByName items name =
+        items |> List.find (fun x -> x.Name = name)
         
     module StandardItem =
         let Vest = "+5 Dexterity Vest"
 
         [<Fact>]
         let ``Standard item degrades quality before "sell in"`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Vest; SellIn = 2; Quality = 20}])
-            let item = findItemByName app Vest
+            let original = {Name = Vest; SellIn = 2; Quality = 20}
 
-            Assert.Equal(20, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(19, item.Quality)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Vest
+            Assert.Equal(original.Quality - 1, result.Quality)
 
 
         [<Fact>]
         let ``Standard item sell in gets reduced`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Vest; SellIn = 2; Quality = 20}])
-            let item = findItemByName app Vest
+            let original = {Name = Vest; SellIn = 2; Quality = 20}
 
-            Assert.Equal(2, item.SellIn)
-            app.UpdateQuality()
-            Assert.Equal(1, item.SellIn)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Vest
+            Assert.Equal(original.SellIn - 1, result.SellIn)
 
         [<Fact>]
         let ``Standard item degrades in quality after "sell in"`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Vest; SellIn = 0; Quality = 20}])
-            let item = findItemByName app Vest
+            let original = {Name = Vest; SellIn = 0; Quality = 20}
 
-            Assert.Equal(20, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(18, item.Quality)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Vest
+            Assert.Equal(original.Quality - 2, result.Quality)
 
         [<Fact>]
         let ``Standard item don't go below 0 quality`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Vest; SellIn = 0; Quality = 0}])
-            let item = findItemByName app Vest
+            let original = {Name = Vest; SellIn = 0; Quality = 0}
+
+            let actual = updateQuality [original]
             
-            Assert.Equal(0, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(0, item.Quality)
+            let result = findItemByName actual Vest
+            Assert.Equal(0, result.Quality)
 
     module SulfurasRules =
         let Sulfuras = "Sulfuras, Hand of Ragnaros"
 
         [<Fact>]
         let ``Sulfuras quality is constant`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Sulfuras; SellIn = 0; Quality = 80}])
-            let item = findItemByName app Sulfuras
+            let original = {Name = Sulfuras; SellIn = 0; Quality = 80}
 
-            Assert.Equal(80, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(80, item.Quality)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Sulfuras
+            Assert.Equal(80, result.Quality)
 
         [<Fact>]
         let ``Sulfuras "sell in" is always Zero`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Sulfuras; SellIn = 0; Quality = 80}])
-            let item = findItemByName app Sulfuras
+            let original = {Name = Sulfuras; SellIn = 0; Quality = 80}
 
-            Assert.Equal(0, item.SellIn)
-            app.UpdateQuality()
-            Assert.Equal(0, item.SellIn)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Sulfuras
+            Assert.Equal(0, result.SellIn)
 
     module BackstageRules =
         let Backstage = "Backstage passes to a TAFKAL80ETC concert"
 
         [<Fact>]
         let ``Backstage goes to zero quality after "sell in"`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Backstage; SellIn = 0; Quality = 3}])
-            let item = findItemByName app Backstage
+            let original = {Name = Backstage; SellIn = 0; Quality = 3}
 
-            Assert.Equal(3, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(0, item.Quality)
+            let actual = updateQuality [original]
+            
+            let result = findItemByName actual Backstage
+            Assert.Equal(0, result.Quality)
 
         [<Fact>]
         let ``Backstage quality goes up by two with 10 or less days`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Backstage; SellIn = 10; Quality = 3}])
-            let item = findItemByName app Backstage
+            let original = {Name = Backstage; SellIn = 10; Quality = 3}
 
-            Assert.Equal(3, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(5, item.Quality)
+            let actual = updateQuality [original]
+            
+            let result = findItemByName actual Backstage
+            Assert.Equal(original.Quality + 2, result.Quality)
 
         [<Fact>]
         let ``Backstage quality goes up by three with 5 or less days`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Backstage; SellIn = 5; Quality = 3}])
-            let item = findItemByName app Backstage
+            let original = {Name = Backstage; SellIn = 5; Quality = 3}
 
-            Assert.Equal(3, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(6, item.Quality)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Backstage
+            Assert.Equal(original.Quality + 3, result.Quality)
 
     module BrieRules =
         let Brie = "Aged Brie"
 
         [<Fact>]
         let ``Aged brie increases quality `` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Brie; SellIn = 2; Quality = 0}])
-            let item = findItemByName app Brie
+            let original = {Name = Brie; SellIn = 2; Quality = 0}
 
-            Assert.Equal(0, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(1, item.Quality)
+            let actual = updateQuality [original]
+
+            let result = findItemByName actual Brie
+            Assert.Equal(1, result.Quality)
 
         [<Fact>]
         let ``Aged brie quality doesn't go over 50`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Brie; SellIn = 2; Quality = 50}])
+            let original = {Name = Brie; SellIn = 2; Quality = 50}
 
-            let item = findItemByName app Brie
+            let actual = updateQuality [original]
 
-            Assert.Equal(50, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(50, item.Quality)
+            let result = findItemByName actual Brie
+            Assert.Equal(original.Quality, result.Quality)
 
         [<Fact>]
         let ``Aged brie quality doesn't increase if already over 50`` () =
-            let app = new Program()
-            app.Items <- ResizeArray<Item>([ {Name = Brie; SellIn = 2; Quality = 51}])
-            let item = findItemByName app Brie
+            let original = {Name = Brie; SellIn = 2; Quality = 51}
+
+            let actual = updateQuality [original]
 
-            Assert.Equal(51, item.Quality)
-            app.UpdateQuality()
-            Assert.Equal(51, item.Quality)
+            let result = findItemByName actual Brie
+            Assert.Equal(original.Quality, result.Quality)
 

          
M tests/GildedRose.Tests/BaseRules.cs +71 -49
@@ 4,6 4,7 @@ using System.Linq;
 using Xunit;
 using GildedRose.Console;
 using GildedRose.FSharp.Library;
+using Microsoft.FSharp.Collections;
 
 namespace GildedRose.Tests
 {

          
@@ 15,7 16,7 @@ namespace GildedRose.Tests
         public const string Sulfuras = "Sulfuras, Hand of Ragnaros";
         public const string Backstage = "Backstage passes to a TAFKAL80ETC concert";
         
-        public Data.Item FindItemByName(IList<Data.Item> items, string name)
+        public Data.Item FindItemByName(FSharpList<Data.Item> items, string name)
         {
             return items.First(x => x.Name.Equals(name));
         }

          
@@ 25,41 26,47 @@ namespace GildedRose.Tests
             [Fact]
             void VestItemDegradesQualityBeforeSellIn()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Vest, 2, 20)}};
-                var item = FindItemByName(app.Items, Vest);
-                Assert.Equal(20, item.Quality);
+                var original = new Data.Item (Vest, 2, 20);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(19, item.Quality);
+
+                var result = FindItemByName(app.Items, Vest);
+                Assert.Equal(original.Quality - 1, result.Quality);
             }
 
             [Fact]
             void AnItemSellInGetsReduced()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Vest, 2, 3)}};
-                var item = FindItemByName(app.Items, Vest);
-                Assert.Equal(2, item.SellIn);
+                var original = new Data.Item (Vest, 2, 3);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(1, item.SellIn);
+
+                var result = FindItemByName(app.Items, Vest);
+                Assert.Equal(original.SellIn - 1, result.SellIn);
             }
 
             [Fact]
             void ItemDegradesQualityTwiceAfterSellIn()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Vest, 0, 3)}};
-                var item = FindItemByName(app.Items, Vest);
-                Assert.Equal(3, item.Quality);
+                var original = new Data.Item (Vest, 0, 3);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+                
                 app.UpdateQuality();
-                Assert.Equal(1, item.Quality);
+                
+                var result = FindItemByName(app.Items, Vest);
+                Assert.Equal(original.Quality - 2 , result.Quality);
             }
 
             [Fact]
             void AnItemDontGoBelowZeroQuality()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item ("Test", 1, 0)}};
-                var item = FindItemByName(app.Items, "Test");
-                Assert.Equal(0, item.Quality);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {new Data.Item ("Test", 1, 0)})};
+
                 app.UpdateQuality();
-                Assert.Equal(0, item.Quality);
+                var result = FindItemByName(app.Items, "Test");
+                Assert.Equal(0, result.Quality);
             }
         }
 

          
@@ 68,21 75,25 @@ namespace GildedRose.Tests
             [Fact]
             void SulfurasQualityIsConstant()
             {
-                var app = new Program() {Items = new List<Data.Item> {new Data.Item (Sulfuras, 0, 80)}};
-                var item = FindItemByName(app.Items, Sulfuras);
-                Assert.Equal(80, item.Quality);
+                var originalQuality = 80;
+                var app = new Program() {Items = ListModule.OfSeq(new List<Data.Item> {new Data.Item (Sulfuras, 0, originalQuality)})};
+                
                 app.UpdateQuality();
-                Assert.Equal(80, item.Quality);
+                
+                var result = FindItemByName(app.Items, Sulfuras);
+                Assert.Equal(originalQuality, result.Quality);
             }
 
             [Fact]
             void SulfurasSellInIsAlwaysZero()
             {
-                var app = new Program() {Items = new List<Data.Item> {new Data.Item (Sulfuras, 0, 80)}};
-                var item = FindItemByName(app.Items, Sulfuras);
-                Assert.Equal(0, item.SellIn);
+                var sellIn = 0;
+                var app = new Program() {Items = ListModule.OfSeq(new List<Data.Item> {new Data.Item (Sulfuras, sellIn, 80)})};
+
                 app.UpdateQuality();
-                Assert.Equal(0, item.SellIn);
+                
+                var result = FindItemByName(app.Items, Sulfuras);
+                Assert.Equal(sellIn, result.SellIn);
             }
         }
 

          
@@ 91,31 102,36 @@ namespace GildedRose.Tests
             [Fact]
             void BackstageGoesToZeroQualityAfterSellIn()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Backstage, 0, 3)}};
-                var item = FindItemByName(app.Items, Backstage);
-                Assert.Equal(3, item.Quality);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {new Data.Item (Backstage, 0, 3)})};
+                
                 app.UpdateQuality();
-                Assert.Equal(0, item.Quality);
+                
+                var result = FindItemByName(app.Items, Backstage);
+                Assert.Equal(0, result.Quality);
             }
 
             [Fact]
             void BackstageGoesQualityByTwoWith10OrLessDays()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Backstage, 10, 3)}};
-                var item = FindItemByName(app.Items, Backstage);
-                Assert.Equal(3, item.Quality);
+                var original = new Data.Item (Backstage, 10, 3);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(5, item.Quality);
+
+                var result = FindItemByName(app.Items, Backstage);
+                Assert.Equal(original.Quality + 2, result.Quality);
             }
 
             [Fact]
             void BackstageGoesQualityByThreeWith5OrLessDays()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Backstage, 5, 3)}};
-                var item = FindItemByName(app.Items, Backstage);
-                Assert.Equal(3, item.Quality);
+                var original = new Data.Item (Backstage, 5, 3);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(6, item.Quality);
+
+                var result = FindItemByName(app.Items, Backstage);
+                Assert.Equal(original.Quality + 3, result.Quality);
             }
         }
 

          
@@ 124,31 140,37 @@ namespace GildedRose.Tests
             [Fact]
             void AgedBriesIncreasesQuality()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Brie, 2, 0)}};
-                var item = FindItemByName(app.Items, Brie);
-                Assert.Equal(0, item.Quality);
+                var original = new Data.Item (Brie, 2, 0);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(1, item.Quality);
+
+                var result = FindItemByName(app.Items, Brie);
+                Assert.Equal(original.Quality + 1, result.Quality);
             }
 
             [Fact]
             void AgedBrieQualityDoesntGoOver50()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Brie, 2, 50)}};
-                var item = FindItemByName(app.Items, Brie);
-                Assert.Equal(50, item.Quality);
+                var original = new Data.Item (Brie, 2, 50);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(50, item.Quality);
+
+                var result = FindItemByName(app.Items, Brie);
+                Assert.Equal(original.Quality, result.Quality);
             }
 
             [Fact]
             void AgedBrieQualityDoesntIncreaseAfter50()
             {
-                var app = new Program() { Items = new List<Data.Item> {new Data.Item (Brie, 2, 51)}};
-                var item = FindItemByName(app.Items, Brie);
-                Assert.Equal(51, item.Quality);
+                var original = new Data.Item (Brie, 2, 51);
+                var app = new Program() { Items = ListModule.OfSeq(new List<Data.Item> {original})};
+
                 app.UpdateQuality();
-                Assert.Equal(51, item.Quality);
+
+                var result = FindItemByName(app.Items, Brie);
+                Assert.Equal(original.Quality, result.Quality);
             }
         }
      }

          
M tests/GildedRose.Tests/GildedRose.Tests.csproj +1 -0
@@ 7,6 7,7 @@ 
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="FSharp.Core" Version="5.0.0" />
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
     <PackageReference Include="xunit" Version="2.4.1" />
     <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">