public void Load_PublishConfiguration_ObjectDeserializerReturnsEmptyPublishConfiguration_ResultIsEmptyPublishConfiguration() { // Arrange PublishConfiguration objectReturnedByDeserializer = new PublishConfiguration(); string storageLocation = "temp-file"; var filesystemAccessor = new Mock<IFilesystemAccessor>(); var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>(); filesystemAccessor.Setup(f => f.FileExists(It.IsAny<string>())).Returns(true); filesystemAccessor.Setup(f => f.GetFileContent(It.IsAny<string>())).Returns("some content"); objectSerializer.Setup(s => s.Deserialize(It.IsAny<string>())).Returns(objectReturnedByDeserializer); var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object); // Act var result = filesystemPersistence.Load(storageLocation); // Assert Assert.AreEqual(objectReturnedByDeserializer, result); }
public void Load_PublishConfiguration_StorageLocationIsInvalid(string storageLocation) { // Arrange var filesystemAccessor = new Mock<IFilesystemAccessor>(); var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>(); var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object); // Act filesystemPersistence.Load(storageLocation); }
public void Load_PublishConfiguration_StorageLocationDoesNotExist_ResultIsNull() { // Arrange string storageLocation = "temp-file"; var filesystemAccessor = new Mock<IFilesystemAccessor>(); var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>(); filesystemAccessor.Setup(f => f.FileExists(It.IsAny<string>())).Returns(false); var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object); // Act var result = filesystemPersistence.Load(storageLocation); // Assert Assert.IsNull(result); }