public void Save_PublishConfiguration_WriteSerializedJsonToStoreageLocation_Suceeeds_ResultIsTrue()
        {
            // Arrange
            var objectToPersist = new PublishConfiguration();
            string storageLocation = "temp-file";

            var filesystemAccessor = new Mock<IFilesystemAccessor>();
            var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>();

            objectSerializer.Setup(o => o.Serialize(It.IsAny<PublishConfiguration>())).Returns("[]");
            filesystemAccessor.Setup(f => f.WriteContentToFile(It.IsAny<string>(), It.IsAny<string>())).Returns(true);

            var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object);

            // Act
            var result = filesystemPersistence.Save(objectToPersist, storageLocation);

            // Assert
            Assert.IsTrue(result);
        }
        public void Save_PublishConfiguration_ObjectToPersistIsNull_ArgumentNullExceptionIsThrown()
        {
            // Arrange
            PublishConfiguration objectToPersist = null;
            string storageLocation = "temp-file";

            var filesystemAccessor = new Mock<IFilesystemAccessor>();
            var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>();

            var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object);

            // Act
            filesystemPersistence.Save(objectToPersist, storageLocation);
        }
        public void Save_PublishConfiguration_StorageLocationIsInvalid_ArgumentExceptionIsThrown(string storageLocation)
        {
            // Arrange
            var objectToPersist = new PublishConfiguration();

            var filesystemAccessor = new Mock<IFilesystemAccessor>();
            var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>();

            var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object);

            // Act
            filesystemPersistence.Save(objectToPersist, storageLocation);
        }
        public void Save_PublishConfiguration_ObjectSerializerReturnInvalidResult_ResultIsFalse(string objectSerializerResult)
        {
            // Arrange
            var objectToPersist = new PublishConfiguration();
            string storageLocation = "temp-file";

            var filesystemAccessor = new Mock<IFilesystemAccessor>();
            var objectSerializer = new Mock<IObjectSerializer<PublishConfiguration>>();

            objectSerializer.Setup(o => o.Serialize(It.IsAny<PublishConfiguration>())).Returns(objectSerializerResult);

            var filesystemPersistence = new FilesystemPersistence<PublishConfiguration>(filesystemAccessor.Object, objectSerializer.Object);

            // Act
            var result = filesystemPersistence.Save(objectToPersist, storageLocation);

            // Assert
            Assert.IsFalse(result);
        }