forked from zompinc/sync-method-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3d7afb
commit bdd854f
Showing
6 changed files
with
194 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Generator.Tests; | ||
|
||
public class ClassTests | ||
{ | ||
[Fact] | ||
public Task ConvertClass() => $$""" | ||
namespace Test; | ||
interface IAsyncFileSystem | ||
{ | ||
Task<string> ReadAllTextAsync(string path); | ||
Task WriteAllTextAsync(string path, string contents); | ||
} | ||
interface IFileSystem : IAsyncFileSystem | ||
{ | ||
string ReadAllText(string path); | ||
void WriteAllText(string path, string contents); | ||
} | ||
[Zomp.SyncMethodGenerator.CreateSyncVersion(Name = "FileSystem")] | ||
internal class AsyncFileSystem : IAsyncFileSystem | ||
{ | ||
public virtual Task<string> ReadAllTextAsync(string path) => Task.FromResult(""); | ||
public virtual Task WriteAllTextAsync(string path, string contents) => Task.CompletedTask; | ||
} | ||
internal partial class FileSystem : AsyncFileSystem, IFileSystem | ||
{ | ||
public override Task<string> ReadAllTextAsync(string path) => Task.FromResult(ReadAllText(path)); | ||
public override Task WriteAllTextAsync(string path, string contents) | ||
{ | ||
WriteAllText(path, contents); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
""".Verify(false, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...sts/Snapshots/ClassTests.ConvertClass#Test.Test.FileSystem.ReadAllTextAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.Test.FileSystem.ReadAllTextAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
internal partial class FileSystem | ||
{ | ||
public virtual string ReadAllText(string path) => ""; | ||
} |
8 changes: 8 additions & 0 deletions
8
...ts/Snapshots/ClassTests.ConvertClass#Test.Test.FileSystem.WriteAllTextAsync.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//HintName: Test.Test.FileSystem.WriteAllTextAsync.g.cs | ||
// <auto-generated/> | ||
#nullable enable | ||
namespace Test; | ||
internal partial class FileSystem | ||
{ | ||
public virtual void WriteAllText(string path, string contents) { } | ||
} |