diff --git a/src/TestabilityKata.Tests/CustomFileWriterTest.cs b/src/TestabilityKata.Tests/CustomFileWriterTest.cs new file mode 100644 index 0000000..b0cf46c --- /dev/null +++ b/src/TestabilityKata.Tests/CustomFileWriterTest.cs @@ -0,0 +1,40 @@ +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.SetAttributes(testFilePath, FileAttributes.Normal); + File.Delete(testFilePath); + } + + var customFileWriter = new CustomFileWriter( + fakeMailSender, + testFilePath); + customFileWriter.AppendLine("Some line"); + + fakeMailSender + .Received() + .SendMail( + Arg.Any(), + Arg.Any()); + } + } +} 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