public void Database_Should_Set_MySQL_DatabaseResource_Correctly() { //Arrang string instance = "example"; MySqlCharset charset = MySqlCharset.utf8; string collation = "collation1"; string userName = "******"; string password = "******"; var fileSystemMock = new Mock <IFileManager>(); fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())) .Verifiable(); string providerPath = @"D:\IGS"; var expected = @"UAT_MySQL.json"; //Act var actual = new Infrastructure("UAT", providerPath, fileSystemMock.Object) .Database().MySQL(instance, charset, collation, userName, password); //Assert Assert.AreEqual(expected, actual); }
public void MySQLResource_Returen_Right_DatabaseResource() { //Arrang string instance = "example"; MySqlCharset charset = MySqlCharset.utf8; string collation = "collation1"; string userName = "******"; string password = "******"; var db = new MySQLResource(instance, charset, collation, userName, password); var expected = new DatabaseResource { Instance = "example", Collation = "collation1", Charset = "utf8", UserName = "******", Password = "******" }; //Act var actual = db.Build(); //Assert Assert.AreEqual(expected, actual); }
public MySQLResource(string instance, MySqlCharset charset, string collation, string userName, string password) { _instance = instance; _charset = charset; _collation = collation; _userName = userName; _password = password; }
public string MySQL(string instance, MySqlCharset charset, string collation, string userName, string password) { var mySql = new MySQLResource(instance, charset, collation, userName, password); var mySqlAttributes = mySql.Build(); var filename = WriteFile(mySqlAttributes, "MySQL"); return(filename); }
public void MySQL_Factory_Should_Save_SQL_Attributes() { //Arrang string _infrastructureName = "Test"; string _providerPath = "path"; string instance = "example"; MySqlCharset charset = MySqlCharset.utf32; string collation = "collation1"; string userName = "******"; string password = "******"; var expectedObject = new DatabaseResource { Instance = instance, Collation = collation, Charset = charset.ToString(), UserName = userName, Password = password }; string subPath = string.Concat(_providerPath, @"\", _infrastructureName, @"\", "Database"); var fileSystemMock = new Mock <IFileManager>(); fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())) .Verifiable(); //Act new DatabaseFactory(_infrastructureName, _providerPath, fileSystemMock.Object) .MySQL(instance, charset, collation, userName, password);; //Assert fileSystemMock .Verify(mock => mock.WriteJsonFile(expectedObject, subPath, "Test_MySQL.json"), Times.Once()); }
public void Provider_Should_Create_MySQL_Database_Infrastructure_Json_File() { //Arrang string instance = "example"; MySqlCharset charset = MySqlCharset.utf32; string collation = "collation1"; string userName = "******"; string password = "******"; var expectedObject = new DatabaseResource { Instance = instance, Collation = collation, Charset = charset.ToString(), UserName = userName, Password = password }; var fileSystemMock = new Mock <IFileManager>(); fileSystemMock.Setup(w => w.WriteJsonFile(It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>())) .Verifiable(); //Act var provider = new Providers.Provider(_providerName, fileSystemMock.Object); var infra = provider.CreateInfrastructure("UAT"); infra.Database().MySQL(instance, charset, collation, userName, password);; //Assert fileSystemMock.Verify(mock => mock.WriteJsonFile(expectedObject, @"c:\test\UAT\Database", "UAT_MySQL.json"), Times.Once()); }