|
| 1 | +using GitHub.Unity; |
| 2 | +using NCrunch.Framework; |
| 3 | +using NSubstitute; |
| 4 | +using NUnit.Framework; |
| 5 | +using TestUtils; |
| 6 | + |
| 7 | +namespace UnitTests |
| 8 | +{ |
| 9 | + [TestFixture, Isolated] |
| 10 | + class GitObjectFactoryTests |
| 11 | + { |
| 12 | + private static readonly SubstituteFactory SubstituteFactory = new SubstituteFactory(); |
| 13 | + |
| 14 | + [Test] |
| 15 | + public void ShouldParseNormalFile() |
| 16 | + { |
| 17 | + NPath.FileSystem = SubstituteFactory.CreateFileSystem(new CreateFileSystemOptions() { |
| 18 | + CurrentDirectory = @"c:\Projects\UnityProject" |
| 19 | + }); |
| 20 | + |
| 21 | + var environment = Substitute.For<IEnvironment>(); |
| 22 | + environment.RepositoryPath.Returns(@"c:\Projects\UnityProject".ToNPath()); |
| 23 | + environment.UnityProjectPath.Returns(@"c:\Projects\UnityProject".ToNPath()); |
| 24 | + |
| 25 | + var gitObjectFactory = new GitObjectFactory(environment); |
| 26 | + var gitStatusEntry = gitObjectFactory.CreateGitStatusEntry("hello.txt", GitFileStatus.Deleted); |
| 27 | + |
| 28 | + Assert.AreEqual(@"c:\Projects\UnityProject\hello.txt", gitStatusEntry.FullPath); |
| 29 | + } |
| 30 | + |
| 31 | + |
| 32 | + [Test] |
| 33 | + public void ShouldParseOddFile() |
| 34 | + { |
| 35 | + NPath.FileSystem = SubstituteFactory.CreateFileSystem(new CreateFileSystemOptions() |
| 36 | + { |
| 37 | + CurrentDirectory = @"c:\Projects\UnityProject" |
| 38 | + }); |
| 39 | + |
| 40 | + var environment = Substitute.For<IEnvironment>(); |
| 41 | + environment.RepositoryPath.Returns(@"c:\Projects\UnityProject".ToNPath()); |
| 42 | + environment.UnityProjectPath.Returns(@"c:\Projects\UnityProject".ToNPath()); |
| 43 | + |
| 44 | + var gitObjectFactory = new GitObjectFactory(environment); |
| 45 | + var gitStatusEntry = gitObjectFactory.CreateGitStatusEntry("c:UsersOculusGoVideo.mp4", GitFileStatus.Deleted); |
| 46 | + |
| 47 | + Assert.AreEqual(@"c:\Projects\UnityProject\c:UsersOculusGoVideo.mp4", gitStatusEntry.FullPath); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
0 commit comments