From 561d934b7d03a488d79879f9f69f173c7ae23f99 Mon Sep 17 00:00:00 2001 From: Mathias Lorenzen Date: Tue, 3 Oct 2017 12:06:32 +0200 Subject: [PATCH 1/4] added new test. --- .../CustomFileWriterTest.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/TestabilityKata.Tests/CustomFileWriterTest.cs diff --git a/src/TestabilityKata.Tests/CustomFileWriterTest.cs b/src/TestabilityKata.Tests/CustomFileWriterTest.cs new file mode 100644 index 0000000..eef7a4b --- /dev/null +++ b/src/TestabilityKata.Tests/CustomFileWriterTest.cs @@ -0,0 +1,39 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace TestabilityKata.Tests +{ + [TestClass] + public class CustomFileWriterTest + { + [TestMethod] + public void WhenCreatingFileAnEmailIsSentOut() + { + var fakeMailSender = Substitute.For(); + + const string testFilePath = @"C:\WhenCreatingFileAnEmailIsSentOut.txt"; + + //if the existing file exists, delete it before running the test, since + //we need to get to the point where a new file is created. + if(File.Exists(testFilePath)) + { + File.Delete(testFilePath); + } + + var customFileWriter = new CustomFileWriter( + fakeMailSender, + testFilePath); + customFileWriter.AppendLine("Some line"); + + fakeMailSender + .Received() + .SendMail( + Arg.Any(), + Arg.Any()); + } + } +} From 34a03c4f902159db990786a9f3f5418c680866cd Mon Sep 17 00:00:00 2001 From: Mathias Lorenzen Date: Tue, 3 Oct 2017 12:15:30 +0200 Subject: [PATCH 2/4] bugfix for test on repeated runs. --- src/TestabilityKata.Tests/CustomFileWriterTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TestabilityKata.Tests/CustomFileWriterTest.cs b/src/TestabilityKata.Tests/CustomFileWriterTest.cs index eef7a4b..b0cf46c 100644 --- a/src/TestabilityKata.Tests/CustomFileWriterTest.cs +++ b/src/TestabilityKata.Tests/CustomFileWriterTest.cs @@ -21,6 +21,7 @@ public void WhenCreatingFileAnEmailIsSentOut() //we need to get to the point where a new file is created. if(File.Exists(testFilePath)) { + File.SetAttributes(testFilePath, FileAttributes.Normal); File.Delete(testFilePath); } From deca5ce0912247bd0b57f3185112af87f25c4cd5 Mon Sep 17 00:00:00 2001 From: Mathias Lorenzen Date: Tue, 19 Oct 2021 10:52:12 +0200 Subject: [PATCH 3/4] indentation. --- src/TestabilityKata/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestabilityKata/Program.cs b/src/TestabilityKata/Program.cs index 7da5f4a..83a2050 100644 --- a/src/TestabilityKata/Program.cs +++ b/src/TestabilityKata/Program.cs @@ -128,7 +128,7 @@ public void AppendLine(string line) lock(typeof(CustomFileWriter)) { if (!File.Exists(FilePath)) { - mailSender.SendMail("mathias.lorenzen@mailinator.com", "The file " + FilePath + " was created since it didn't exist."); + mailSender.SendMail("mathias.lorenzen@mailinator.com", "The file " + FilePath + " was created since it didn't exist."); File.WriteAllText(FilePath, ""); } From cdf0b18012c1efb055ddcfe43920c0af975ad9a4 Mon Sep 17 00:00:00 2001 From: Mathias Date: Wed, 15 Jun 2022 08:30:33 +0200 Subject: [PATCH 4/4] Updated packages. --- .../TestabilityKata.Tests.csproj | 12 ++++++------ src/TestabilityKata/TestabilityKata.csproj | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/TestabilityKata.Tests/TestabilityKata.Tests.csproj b/src/TestabilityKata.Tests/TestabilityKata.Tests.csproj index f8c14f3..14ce7f0 100644 --- a/src/TestabilityKata.Tests/TestabilityKata.Tests.csproj +++ b/src/TestabilityKata.Tests/TestabilityKata.Tests.csproj @@ -1,17 +1,17 @@ - netcoreapp2.0 + net6.0 false - - - - - + + + + + diff --git a/src/TestabilityKata/TestabilityKata.csproj b/src/TestabilityKata/TestabilityKata.csproj index ce1697a..41f1d5a 100644 --- a/src/TestabilityKata/TestabilityKata.csproj +++ b/src/TestabilityKata/TestabilityKata.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + net6.0