Srinivas Miriyala's Blog


Thursday, March 26, 2015

Unit Testing the Console Applications with ReadLine and WriteLine methods

public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Enter your name.");
        string name = Console.ReadLine();
        Console.WriteLine("Hello, {0}.", name);
        Console.WriteLine("Type a message.");
        string message = Console.ReadLine();
        Console.WriteLine("You wrote: {0}", message);
    }
}




[TestMethod]
public void RunMain()
{
    using (StringWriter sw = new StringWriter())
    {
        Console.SetOut(sw);
 
        using (StringReader sr = new StringReader(string.Format("Mark{0}Ploeh{0}",
            Environment.NewLine)))
        {
            Console.SetIn(sr);
 
            Program.Main(new string[] { });
 
            string expected = string.Format(
                "Enter your name.{0}Hello, Mark.{0}Type a message.{0}You wrote: Ploeh{0}",
                Environment.NewLine);
            Assert.AreEqual<string>(expected, sw.ToString());
        }
    }
}




For more details :
http://blogs.msdn.com/b/ploeh/archive/2006/10/21/consoleunittesting.aspx

Wednesday, May 14, 2014

When the EditorPackage does not load correctly









Something must have changed with the Windows updates and it was enough to cause an issue. This problem seems happens enough with various versions of Visual Studio that you can bingle it and get the same answer.  You need to clear the ComponentModelCache folder.  For Visual Studio 2013, it’s located in the %LOCALAPPDATA%\Microsoft\VisualStudio\12.0 folder.


I renamed ComponentModelCache to ComponentModelCache.Borked and restarted Visual Studio.  It started right up and without any errors.








Source :
http://www.rajapet.com/2014/02/when-the-editorpackage-does-not-load-correctly.html





Tuesday, June 28, 2011

Run SQL scripts in Multiple Databases


http://www.codeproject.com/Tips/121991/SQL-Deployment-Tool-for-Multiple-Databases

Monday, June 27, 2011

UltraGrid: Remove/Change selected Row color

If you want to remove selected row color(by default blue) and preserve your cell colors, follow this procedure.

Private Sub grid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grid1.InitializeLayout

'Make selected row color to transparant
e.Layout.SelectionOverlayColor = SystemColors.Highlight
'remove slected and active appearance
With e.Layout.Bands(0)
.Override.SelectedAppearancesEnabled = DefaultableBoolean.False
.Override.ActiveAppearancesEnabled = DefaultableBoolean.False
End With

End Sub

Labels: , , , ,

Friday, June 4, 2010

Open a WPF Window from WinForms

using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;

var wpfwindow= new WPFApplication1.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();

The EnableModelessKeyboardInterop() call is necessary to handle keyboard input in the WPF window if loaded from a non-WPF host like WinForms. I understand there are other ways to do this and you can read more about WPF/WinForms interop here.

Tuesday, March 30, 2010

UltraGrid - Change Header Properties

' Get the band to hide the headers in.
Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)

' You can hide the column headers by setting ColHeadersVisible to false. By
' default, column headers are visible.
band.ColHeadersVisible = False

' You can hide the group headers by setting GroupHeadersVisible to false. By
' default, group headers are visible.
band.GroupHeadersVisible = False

' You can also show the band header which by default is hidden by setting
' the HeaderVisible property to true.
band.HeaderVisible = True

' You can also set the caption of the band header.
band.Header.Caption = "Customers Table"

' You can also set the apperance of the band header using Appearance property
' off the header.
band.Header.Appearance.BackColor = Color.DarkBlue
band.Header.Appearance.ForeColor = Color.LightYellow

' You can use the HeaderPlacement property to specify how headers are displayed.
band.Override.HeaderPlacement = HeaderPlacement.FixedOnTop

Friday, March 12, 2010

UltraWinGrid Disable Autogenerated Columns

use SetDataBinding method instead of assigning data to DataSource property.

UltraGrid1.SetDataBinding(DataTable1, Nothing, True)

Labels: , ,