Posted on January 29, 2008
Filed Under Uncategorized | 2 Comments
Visual Studio and TortoiseSVN
Posted on January 10, 2008
TortoiseSVN is an excelent subversion client. But I hate switching windows just to update the repo.
So I defined two external commands in VS and binded them to F1 and Alt+F1.
Commit
C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
/command:commit /notempfile /path:”$(SolutionDir)”
$(SolutionDir)
Update
C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
/command:update /path:”$(SolutionDir)” /rev /notempfile
$(SolutionDir)
And vuala, a decent integration.
(I really wish svn had local commit, I may switch to git/mercurial just for that).
Filed Under Uncategorized | Leave a Comment
How to make some things mockable
Posted on January 8, 2008
Suppose I want to test something, but there is no supported way to do this.
For example I have a method that uses base class method RenderText to display JSON skipping the view. I would really like to capture the output to make sure that correct string is generated. Regular testing techniques did not work in this case. So here is a simple solution.
1. Create an interface that will mimic the methods of base class you want to test.
2. Implement that interface in your base class.
3. In the base class create a property of interface type and create a mutator to allow you to set new instance.
4. In the Base class constructor set this property to this class instance.
Example in code:
class ClassWithMethodIwantToTest
void RenderText(string);
interface InterfaceIwantToMakeTastable
void RenderText(string);
class MyBaseClass extends ClassWithMethodIwantToTest implements InterfaceIwantToMakeTastable
InterfaceIwantToMakeTastable SomeVariable
get;
set;
Constructor MyBaseClass()
SomeVariable = this;
class MyRealClassThatWillRuleTheWorld extends MyBaseClass
void SomeMethod()
SomeVariable.RenderText("i'm ok!");
And now in your test you can provide mocked version of the InterfaceIwantToMakeTastable and capture information you need.
Because I change the structure of my code and make it more complex just to make it testable, this is the case where I would have liked to have ability to provide custom version of the method to a class instance. But hey it’s better then untested code!
Filed Under Uncategorized | 2 Comments
On the the being too geeky at your own expense
Posted on January 7, 2008
When I named my coputer 0xCAFE i knew I might have trouble. Oh well.
Windows thinks that localhost == hostname, which is probably incorrect if I use localhost explicitly.
Server Error in ‘/’ Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Source Error:
Line 54: // Drops previous the schema
Line 55: ActiveRecordStarter.DropSchema();Source File: C:\Documents and Settings\Iouri Goussev\My Documents\Projects\drl\MixMaster\MixMaster\GlobalApplication.cs Line: 55
Stack Trace:
[SqlException (0×80131904): An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +737554
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +114
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
NHibernate.Connection.DriverConnectionProvider.GetConnection() in I:\Castle Source Code\Hibernate\src\NHibernate\Connection\DriverConnectionProvider.cs:46
NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, Boolean export, Boolean justDrop, Boolean format) in I:\Castle Source Code\Hibernate\src\NHibernate\Tool\hbm2ddl\SchemaExport.cs:263[HibernateException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, Boolean export, Boolean justDrop, Boolean format) in I:\Castle Source Code\Hibernate\src\NHibernate\Tool\hbm2ddl\SchemaExport.cs:276
NHibernate.Tool.hbm2ddl.SchemaExport.Drop(Boolean script, Boolean export) in I:\Castle Source Code\Hibernate\src\NHibernate\Tool\hbm2ddl\SchemaExport.cs:101
Castle.ActiveRecord.ActiveRecordStarter.DropSchema() in I:\Castle Source Code\1.0.x-RC3\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:279[ActiveRecordException: Could not drop the schema]
Castle.ActiveRecord.ActiveRecordStarter.DropSchema() in I:\Castle Source Code\1.0.x-RC3\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:283
MixMaster.GlobalApplication.CreateDatase() in C:\Documents and Settings\Iouri Goussev\My Documents\Projects\drl\MixMaster\MixMaster\GlobalApplication.cs:55
MixMaster.GlobalApplication.Application_OnStart() in C:\Documents and Settings\Iouri Goussev\My Documents\Projects\drl\MixMaster\MixMaster\GlobalApplication.cs:34[Exception: An exception happened on Global application or on a module that run before MonoRail’s module. MonoRail will not be initialized and further requests are going to fail. Fix the cause of the error reported below.]
Castle.MonoRail.Framework.EngineContextModule.Init(HttpApplication context) in I:\Castle Source Code\1.0.x-RC3\MonoRail\Castle.MonoRail.Framework\EngineContextModule.cs:46
System.Web.HttpApplication.InitModulesCommon() +66
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1006
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +259
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +114
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
and
ping 0xCAFE
Pinging 0.0.202.254 with 32 bytes of data
Filed Under Uncategorized | Leave a Comment
