public void Database_Should_Set_SQL_DatabaseResource_Correctly() { //Arrang string instance = "example"; SqlCharset charset = SqlCharset.utf32; 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_SQL.json"; //Act var actual = new Infrastructure("UAT", providerPath, fileSystemMock.Object) .Database().SQL(instance, charset, collation, userName, password); //Assert Assert.AreEqual(expected, actual); }
public void SQLResource_Returen_Right_DatabaseResource() { //Arrang string instance = "example"; SqlCharset charset = SqlCharset.utf32; string collation = "collation1"; string userName = "******"; string password = "******"; var db = new SQLResource(instance, charset, collation, userName, password); var expected = new DatabaseResource { Instance = "example", Collation = "collation1", Charset = "utf32", UserName = "******", Password = "******" }; //Act var actual = db.Build(); //Assert Assert.AreEqual(expected, actual); }
public SQLResource(string instance, SqlCharset charset, string collation, string userName, string password) { _instance = instance; _charset = charset; _collation = collation; _userName = userName; _password = password; }
public string SQL(string instance, SqlCharset charset, string collation, string userName, string password) { var sql = new SQLResource(instance, charset, collation, userName, password); var sqlAttributes = sql.Build(); var filename = WriteFile(sqlAttributes, "SQL"); return(filename); }
public void SQL_Factory_Should_Save_SQL_Attributes() { //Arrang string _infrastructureName = "Test"; string _providerPath = "path"; string instance = "example"; SqlCharset charset = SqlCharset.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) .SQL(instance, charset, collation, userName, password);; //Assert fileSystemMock .Verify(mock => mock.WriteJsonFile(expectedObject, subPath, "Test_SQL.json"), Times.Once()); }
public void Provider_Should_Create_SQL_Database_Infrastructure_Json_File() { //Arrang string instance = "example"; SqlCharset charset = SqlCharset.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().SQL(instance, charset, collation, userName, password);; //Assert fileSystemMock.Verify(mock => mock.WriteJsonFile(expectedObject, @"c:\test\UAT\Database", "UAT_SQL.json"), Times.Once()); }