public void ReadReturnsExistingMetadataInfo()
        {
            // Arrange

            const string savedData =
                "[{\"FullName\":\"ItemFullName\",\"ProjectDisplayName\":\"ItemProjectDisplayName\",\"ProjectFullName\":\"ItemProjectFullName\"}]\r\n";

            var ioService = Mock.Of <IIOService>(s =>
                                                 s.GetReader(It.IsAny <string>()) == Mock.Of <TextReader>(r =>
                                                                                                          r.ReadToEnd() == savedData));

            var service = new PinnedItemStorageService(ioService);

            // Act

            var info = service.Read("FullName");

            // Assert

            var item = info.Single();

            Assert.AreEqual("ItemFullName", item.FullName);
            Assert.AreEqual("ItemProjectDisplayName", item.ProjectDisplayName);
            Assert.AreEqual("ItemProjectFullName", item.ProjectFullName);
        }
        public void ExceptionIsThrownWhenFullNameIsEmptyWhenGettingReader(string fullName)
        {
            // Arrange

            var service = new PinnedItemStorageService(
                Mock.Of <IIOService>());

            // Act, Assert

            Assert.Throws <ArgumentException>(() =>
                                              service.Read(fullName));
        }
        public void ReadReturnsEmptyMetadataInfoListIfFileDoesNotExist()
        {
            // Arrange

            var service = new PinnedItemStorageService(
                Mock.Of <IIOService>());

            // Act

            var info = service.Read("FullName");

            // Assert

            Assert.IsEmpty(info);
        }
        public void ReaderIsDisposed()
        {
            // Arrange

            using (var reader = new TestingTextReader())
            {
                var ioService = Mock.Of <IIOService>(s =>
                                                     s.GetReader(It.IsAny <string>()) == reader);

                var service = new PinnedItemStorageService(ioService);

                // Act

                service.Read("FullName");

                // Assert

                Assert.IsTrue(reader.DisposeInvoked);
            }
        }
        public void FullNameIsHashedWhenRequestingReader()
        {
            // Arrange

            using (var reader = new TestingTextReader())
            {
                var ioService = Mock.Of <IIOService>(s =>
                                                     s.GetReader(It.IsAny <string>()) == reader);

                var service = new PinnedItemStorageService(ioService);

                // Act

                service.Read(FullName);

                // Assert

                Mock.Get(ioService).Verify(s =>
                                           s.GetReader(_hashedPath));
            }
        }