コード例 #1
0
        public void ShouldParseNormalFile()
        {
            NPath.FileSystem = SubstituteFactory.CreateFileSystem(new CreateFileSystemOptions()
            {
                CurrentDirectory = @"c:\Projects\UnityProject"
            });

            var environment = Substitute.For <IEnvironment>();

            environment.RepositoryPath.Returns(@"c:\Projects\UnityProject".ToNPath());
            environment.UnityProjectPath.Returns(@"c:\Projects\UnityProject".ToNPath());

            var gitObjectFactory = new GitObjectFactory(environment);
            var gitStatusEntry   = gitObjectFactory.CreateGitStatusEntry("hello.txt", GitFileStatus.None, GitFileStatus.Deleted);

            Assert.AreEqual(@"c:\Projects\UnityProject\hello.txt", gitStatusEntry.FullPath);
        }
コード例 #2
0
        public void ShouldInitializeWhenCacheDoesNotExist()
        {
            const string connectionsCachePath = @"c:\UserCachePath\";

            var fileSystem = SubstituteFactory.CreateFileSystem();

            NPath.FileSystem = fileSystem;

            var credentialManager = Substitute.For <ICredentialManager>();

            var environment = SubstituteFactory.CreateEnvironment();

            environment.UserCachePath.Returns(info => connectionsCachePath.ToNPath());
            environment.FileSystem.Returns(fileSystem);

            var keychain = new Keychain(environment, credentialManager);

            keychain.Initialize();

            fileSystem.Received(1).FileExists(@"c:\UserCachePath\connections.json");
            fileSystem.DidNotReceive().FileDelete(Args.String);
            fileSystem.DidNotReceive().ReadAllText(Args.String);
            fileSystem.DidNotReceive().ReadAllLines(Args.String);
            fileSystem.DidNotReceive().WriteAllText(Args.String, Args.String);
            fileSystem.DidNotReceive().WriteAllLines(Args.String, Arg.Any <string[]>());

            credentialManager.DidNotReceive().Load(Args.UriString);
            credentialManager.DidNotReceive().HasCredentials();
            credentialManager.DidNotReceive().Delete(Args.UriString);
            credentialManager.DidNotReceive().Save(Arg.Any <ICredential>());

            keychain.HasKeys.Should().BeFalse();
            keychain.Hosts.Should().BeEmpty();
        }
コード例 #3
0
        private static GitConfig LoadGitConfig(string configFileContents)
        {
            var input = configFileContents.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            const string configFilePath = @"c:\gitconfig.txt";

            var fileSystem = SubstituteFactory.CreateFileSystem(
                new CreateFileSystemOptions
            {
                FileContents = new Dictionary <string, IList <string> > {
                    { configFilePath, input }
                }
            });

            NPath.FileSystem = fileSystem;

            return(new GitConfig(configFilePath));
        }