public void LogToFileShouldWriteAllText() { var publishMetrics = new TextFileTelemetryPublisher(); var dummyDictionary = new Dictionary <string, object>(); var mockFileHelper = new Mock <IFileHelper>(); dummyDictionary.Add("DummyMessage://", "DummyValue"); dummyDictionary.Add("Dummy2", "DummyValue2"); // Act. publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); // Verify. mockFileHelper.Verify(fh => fh.WriteAllTextToFile(It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public void LogToFileShouldCreateDirectoryIfNotExists() { var publishMetrics = new TextFileTelemetryPublisher(); var dummyDictionary = new Dictionary <string, object>(); var mockFileHelper = new Mock <IFileHelper>(); mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny <string>())).Returns(false); dummyDictionary.Add("DummyMessage://", "DummyValue"); dummyDictionary.Add("Dummy2", "DummyValue2"); // Act. publishMetrics.LogToFile("dummyevent", dummyDictionary, mockFileHelper.Object); // Verify. mockFileHelper.Verify(fh => fh.CreateDirectory(It.IsAny <string>()), Times.Once); }