private CommandData MockUpReadHitData(CommandData returnData) { string data = null; if (returnData != null) { data = HitDataTestHelper.ConvertToJson(returnData); } _fileManager.Exists(_localAppDataHitsFile).Returns(data != null); _fileManager.ReadAllText(_localAppDataHitsFile).Returns(data); return(returnData); }
public void LogCurrentDirectory_existingDir_incrementsHitCount() { var expectedName = "Hello"; var expectedFolder = "C:\\Junk\\Folder\\"; var expected = HitDataTestHelper.BuildHelperData(expectedName, expectedFolder); _hitRepo.Load().Returns(expected); _repoPaths.RepositoryFolder.Returns(expectedFolder); _manager.LogCurrentDirectory(); _hitRepo.Received(1).Save(Arg.Is <CommandData>(s => s.Repositories[0].HitCount == 2)); }
public void ReadHitData_existing_file() { var expectedName = "Hello"; var expectedFolder = "There"; var expected = HitDataTestHelper.BuildHelperData(expectedName, expectedFolder); MockUpReadHitData(expected); var data = _repo.Load(); Assert.NotNull(data); Assert.NotNull(data.Repositories); Assert.AreEqual(1, data.Repositories.Count); Assert.AreEqual(expectedName, data.Repositories[0].Name); Assert.AreEqual(expectedFolder, data.Repositories[0].Directory); }