public void TestSqlContextGetConf() { // arrange const string key = "key"; const string value = "value"; mockSqlContextProxy.Setup(m => m.GetConf(key, "")).Returns(value); var mockSparkContextProxy = new Mock <ISparkContextProxy>(); var mockSparkSessionProxy = new Mock <ISparkSessionProxy>(); var mockCatalogProxy = new Mock <ICatalogProxy>(); mockCatalogProxy.Setup(m => m.RefreshTable(It.IsAny <string>())); mockSparkSessionProxy.Setup(m => m.GetCatalog()).Returns(mockCatalogProxy.Object); mockSparkContextProxy.Setup(m => m.CreateSparkSession()).Returns(mockSparkSessionProxy.Object); mockSparkSessionProxy.Setup(m => m.SqlContextProxy).Returns(mockSqlContextProxy.Object); var mockSparkConfProxy = new Mock <ISparkConfProxy>(); mockSparkConfProxy.Setup(m => m.GetSparkConfAsString()) .Returns("spark.master=master;spark.app.name=appname;config1=value1;config2=value2;"); var conf = new SparkConf(mockSparkConfProxy.Object); var sqlContext = new SqlContext(new SparkContext(mockSparkContextProxy.Object, conf)); sqlContext.SparkSession.SparkSessionProxy = mockSparkSessionProxy.Object; //act var actualValue = sqlContext.GetConf(key, ""); // assert Assert.AreEqual(value, actualValue); }
public void TestSqlContextGetConf() { // arrange const string key = "key"; const string value = "value"; mockSqlContextProxy.Setup(m => m.GetConf(key, "")).Returns(value); var sqlContext = new SqlContext(new SparkContext("", ""), mockSqlContextProxy.Object); // act var actualValue = sqlContext.GetConf(key, ""); // assert Assert.AreEqual(value, actualValue); }