public void ExecuteEmptyScript() { IResource scriptResource = new StringResource(""); mocks.ReplayAll(); SimpleAdoTestUtils.ExecuteSqlScript(adoTemplate, scriptResource, false, SimpleAdoTestUtils.BLOCKDELIM_GO_EXP); mocks.VerifyAll(); }
public void HashcodeIsCalculatedUsingResourceOnly() { StringResource testResource = new StringResource("test"); EncodedResource er1 = new EncodedResource(testResource, Encoding.ASCII, true); EncodedResource er2 = new EncodedResource(testResource, Encoding.UTF8, false); Assert.AreEqual(testResource.GetHashCode(), er1.GetHashCode()); Assert.AreEqual(er1.GetHashCode(), er2.GetHashCode()); }
public void ExecuteSingleStatement() { IResource scriptResource = new StringResource("statement 1"); Expect.Call(adoTemplate.ExecuteNonQuery(CommandType.Text, "statement 1")).Return(0); mocks.ReplayAll(); SimpleAdoTestUtils.ExecuteSqlScript(adoTemplate, scriptResource, false, SimpleAdoTestUtils.BLOCKDELIM_GO_EXP); mocks.VerifyAll(); }
public void ExecuteScriptWithMissingSeparatorOnLastBlock() { IResource scriptResource = new StringResource("\tstatement 1 \n\n\t GO\t \n statement 2"); Expect.Call(adoTemplate.ExecuteNonQuery(CommandType.Text, "\tstatement 1 \n")).Return(0); Expect.Call(adoTemplate.ExecuteNonQuery(CommandType.Text, "\n statement 2")).Return(0); mocks.ReplayAll(); SimpleAdoTestUtils.ExecuteSqlScript(adoTemplate, scriptResource, false, SimpleAdoTestUtils.BLOCKDELIM_GO_EXP); mocks.VerifyAll(); }
public void AcceptsNullContent() { Encoding utf7 = new UTF7Encoding(); StringResource r = new StringResource(null, utf7); Assert.AreEqual(string.Empty, r.Content); Stream stm = r.InputStream; Assert.IsTrue(stm.CanRead); Assert.IsNotNull(stm); Assert.AreEqual(0, stm.Length); stm.Close(); }
public void AppliesTxAttributeDrivenAttributes() { StringResource appCtxCfg = new StringResource( APPCTXCFG_START + "<tx:attribute-driven transaction-manager='otherTxManager' proxy-target-type='true' order='2' />" + APPCTXCFG_END); IApplicationContext appCtx = new ResourceXmlApplicationContext(appCtxCfg); // DefaultAdvisorAutoProxyCreator daapc = (DefaultAdvisorAutoProxyCreator) appCtx.GetObject(AopNamespaceUtils.AUTO_PROXY_CREATOR_OBJECT_NAME); // Assert.AreEqual(2, daapc.Order); }
public void ReturnsCorrectEncodedStream() { string FOO_CONTENT = "foo\u4567"; StringResource r = new StringResource(FOO_CONTENT, Encoding.GetEncoding("utf-16")); Assert.AreEqual(FOO_CONTENT, r.Content); Stream istm = r.InputStream; Assert.IsTrue(istm.CanRead); byte[] chars = new byte[istm.Length]; istm.Read(chars, 0, chars.Length); istm.Close(); string result = Encoding.GetEncoding("utf-16").GetString( chars ); Assert.AreEqual(FOO_CONTENT, result); }
public void EnsureDefaults() { Encoding enc = Encoding.Default; string FOO_CONTENT = "foo"; string FOO_DESCRIPTION = "foo description"; StringResource r = new StringResource(FOO_CONTENT); Assert.AreEqual(FOO_CONTENT, r.Content); Assert.AreEqual(enc, r.Encoding); Assert.AreEqual(string.Empty, r.Description); enc = new UTF7Encoding(); r = new StringResource(FOO_CONTENT, enc, FOO_DESCRIPTION); Assert.AreEqual(FOO_CONTENT, r.Content); Assert.AreEqual(enc, r.Encoding); Assert.AreEqual(FOO_DESCRIPTION, r.Description); }
public void ExecuteScriptWithSemicolonSeparatedStatements() { IResource scriptResource = new StringResource("\tstatement 1 ;\nGO\n statement 2;"); Expect.Call(adoTemplate.ExecuteNonQuery(CommandType.Text, "\tstatement 1 ")).Return(0); Expect.Call(adoTemplate.ExecuteNonQuery(CommandType.Text, "\nGO\n statement 2")).Return(0); mocks.ReplayAll(); SimpleAdoTestUtils.ExecuteSqlScript(adoTemplate, scriptResource, false, SimpleAdoTestUtils.BLOCKDELIM_SEMICOLON_EXP); mocks.VerifyAll(); }
public void DoesntSupportRelativeResources() { StringResource r = new StringResource(string.Empty); Assert.Throws <NotSupportedException>(() => r.CreateRelative("foo")); }
public void AlwaysExists() { StringResource r = new StringResource(null); Assert.IsTrue(r.Exists); r = new StringResource(string.Empty); Assert.IsTrue(r.Exists); r = new StringResource("foo"); Assert.IsTrue(r.Exists); }
public void DoesntSupportRelativeResources() { StringResource r = new StringResource(string.Empty); r.CreateRelative("foo"); }
public void DoesntSupportRelativeResources() { StringResource r = new StringResource(string.Empty); Assert.Throws<NotSupportedException>(() => r.CreateRelative("foo")); }