Skip to content

Instantly share code, notes, and snippets.

View Ganeshcse's full-sized avatar

Ganesh Ganeshcse

  • Bangalore, India
View GitHub Profile
// This utility is build using Nunit framework like other NUnit tests.
// My main goal of this utility is,
// if there is any exceptions then I have to fail my unit test.
// for any if conditions, instead of using a if...else, I have to fail my unit test.
// To achieve this, I am using Assert.Fail where ever necessary. Like few sample'e are below.
//if(value == null)
//{
//Assert.Fail("Value cannot be null in this case");
@Ganeshcse
Ganeshcse / MainFile.cs
Last active November 19, 2021 02:20
Async calls
class Session
{
private List<UseCase> useCaseList;
public void ExecuteSession()
{
foreach(var useCase in useCaseList)
{
useCase.ExecuteUseCase();
// Probelm is here. The next use case starts executing before completion of the previous use-case.
interface IMediatorMessage
{
}
interface IMessageHandler<T> where T : IMediatorMessage
{
void Handle(T message);
}
// Object which should be returned as out parameter from another mock object
var mockedObject = MockRepository.GenerateMock<IRealTimeData>();
mockedObject.Expect(x => x.HeatValue).Return(30);
// Mock object which has method GetRealTimeData(out var ...) with out params as IRealTimeData
serverMockObject.Expect(x => x.GetRealTimeData(out _)).OutRef(mockedObject).Return(true);
var actualValue = serice.GetHeatValue();
// Inside the implementation of above method, see below.
public class BarControl
{
public Brush BarBrush { get; set; }
public double BarHeight { get; set; }
public int BarValue { get; set; }
public double BarWidth { get; set; }
<Style TargetType="{x:Type local:StagedProgressBar}">
<Setter Property="BorderBrush" Value="Black"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="Foreground" Value="Black"></Setter>
<Setter Property="Background" Value="#e6e6e6"></Setter>
<Setter Property="Border.CornerRadius" Value="5"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="Template">
<Setter.Value>
private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
{
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
int MONITOR_DEFAULTTONEAREST = 0x00000002;
IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
if (monitor != IntPtr.Zero)
{
MONITORINFO monitorInfo = new MONITORINFO();
System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(Response));
using (StringReader sr = new StringReader(categories))
{
var result = ser.Deserialize(sr);
}
[Serializable, XmlRoot("response")]
public class Response
{
<DataGrid Grid.Row="1" x:Name="DataGrid" HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding PersonDetails}">
<!--<DataGrid.Resources>
<local:OneReturnsTrueConverter x:Key="OneReturnsTrueConverter"/>
<ContextMenu x:Key="DataRowContextMenu">
<MenuItem x:Name="RowContMenuProp" Header="Properties"
DataContext="{Binding Parent.PlacementTarget.Tag , RelativeSource={RelativeSource Self}}"
IsEnabled="{Binding Path=IsMarried, Converter={StaticResource OneReturnsTrueConverter}}" />
</ContextMenu>
</DataGrid.Resources>-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration >
<add key="Mode" value="NoMode"/>
</configuration>