File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
LinkDotNet.Blog.UnitTests/Web/Shared/Services Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . IO ;
3
+ using System . Threading . Tasks ;
4
+ using FluentAssertions ;
5
+ using LinkDotNet . Blog . Web . Shared . Services ;
6
+ using Xunit ;
7
+
8
+ namespace LinkDotNet . Blog . UnitTests . Web . Shared . Services
9
+ {
10
+ public sealed class XmlFileWriterTests : IDisposable
11
+ {
12
+ private const string OutputFilename = "somefile.txt" ;
13
+
14
+ [ Fact ]
15
+ public async Task ShouldWriteToFile ( )
16
+ {
17
+ var myObj = new MyObject { Property = "Prop" } ;
18
+
19
+ await new XmlFileWriter ( ) . WriteObjectToXmlFileAsync ( myObj , OutputFilename ) ;
20
+
21
+ var content = await File . ReadAllTextAsync ( OutputFilename ) ;
22
+ content . Should ( ) . NotBeNull ( ) ;
23
+ content . Should ( ) . Contain ( "<MyObject" ) ;
24
+ content . Should ( ) . Contain ( "<Property>Prop</Property>" ) ;
25
+ }
26
+
27
+ public void Dispose ( )
28
+ {
29
+ if ( File . Exists ( OutputFilename ) )
30
+ {
31
+ File . Delete ( OutputFilename ) ;
32
+ }
33
+ }
34
+
35
+ public class MyObject
36
+ {
37
+ public string Property { get ; set ; }
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments