Saturday, December 8, 2012

Wcf Service Testing

1. Run the Wcf calculator service from H:\Anurag\Technical\WCF\Calc_Svc\Calc1
Calculator service is build as per following article

http://www.c-sharpcorner.com/UploadFile/mahakgupta/a-simple-example-of-wcf-service/

More details about the WCF service- http://www.codeproject.com/Articles/18589/Writing-your-first-WCF-Service

2. Then use the Calc_svc_test which is consuming the above Calc service-
H:\Anurag\Technical\WCF\Calc_Svc\Calc_svc_test

3. The above solution Calc_svc_test will be used for testing an asmx currency convertor service as well -
http://www.webservicex.net/CurrencyConvertor.asmx

For testing this service an Excel based test data will be used. For reading the data from Excel sheet a code has been solution is developed which will be merged to Calc_svc_test later

H:\Anurag\Technical\ExcelReader\XcelReader
(http://csharp.net-informations.com/excel/csharp-read-excel.htm)

4. How to write a C program using VSTS 2010
http://www.youtube.com/watch?v=-Ou7Jxtbafw
http://dotnet.dzone.com/news/how-write-and-run-c-program

Thursday, April 7, 2011

Intw Questions Part4 (Initto)

difference b/w Method overloading & Method Overriding

difference between Multiple Inheritance & Interface

Difference b/w Stored Proc and triggers

sp and trigger are both predefined set of sql statements
1. SP may Return a value but Trigger Not,
2. In SP you can pass parameter But in trigger you can't
3. we explicitly call the Sp when Trigger are implicitly 
fired
4. you can write a sp in Trigger but in a Trigger you cant 
write SP.
5. Trigger written on an individual Table or View where SP 
is written for an Database
6. In case of sql queries,it is possible to compile one query 
at a time,but incase of stored procedure we can compile 
bunch of queries at a time and also it is need at first 
time only,suppose we need modification on queries,after 
modifications no need to compile again in case of stored 
procedures,but in case of sql queries we have to compile 
every time.Stored procedure contain queries in compiled 
format so execution also fast and tome saving. 


Difference b/w Left Outer Join & Inner Join 
    What are Delegates?
    • Delegates are just function pointers, That is, they hold references to functions.
    • A Delegate is a class. When you create an instance of it, you pass in the function name (as a parameter for the delegate's constructor) to which this delegate will refer.
    • Delegates allow methods to be passed as parameters
    • Delegate is a type which  holds the method(s) reference in an object
    • Effective use of delegate improves the performance of application
    Public delegate double Delegate_Prod(int a,int b);
    class Class1
    {
        static double fn_Prodvalues(int val1,int val2)
        {
            return val1*val2;
        }
        static void Main(string[] args)
        {
            //Creating the Delegate Instance
            Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);
            Console.Write("Please Enter Values");
            int v1 = Int32.Parse(Console.ReadLine());
            int v2 = Int32.Parse(Console.ReadLine());
            //use a delegate for processing
            double res = delObj(v1,v2);
            Console.WriteLine ("Result :"+res);
            Console.ReadLine();
        }
    }

    Here I have used a small program which demonstrates the use of delegate.
    The delegate "Delegate_Prod" is declared with double return type and accepts only two integer parameters.
    Inside the class, the method named fn_Prodvalues is defined with double return type and two integer parameters. (The delegate and method have the same signature and parameter type.)
    Inside the Main method, the delegate instance is created and the function name is passed to the delegate instance as follows:

    Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);
    After this, we are accepting the two values from the user and passing those values to the delegate as we do using method:

    delObj(v1,v2);
    Here delegate object encapsulates the method functionalities and returns the result as we specified in the method.
     What is Multicast Delegate?

    It is a delegate which holds the reference of more than one method.
    Multicast delegates must contain only methods that return void, else there is a run-time exception

    What are Events?
    • Events are variables of type delegates.
    • if you want to declare an event, you just declare a variable of type some delegate and put event keyword before your declaration e.g. 
                                                      public event NumberReachedEventHandler NumberReached;
    •  
    What are function pointers?

    Query to retrieve number of records from a table apart from Count (*) 

    select MAX(en) AS A from (
    select ROW_NUMBER() OVER( ORDER BY companyname ) AS en from TSQL2012.Production.Suppliers)
    as An


    How to set up Functional & Performance test environment

    Functional test case techniques (Galax e Solutions)

    Web Services testing in different environments e.g. Functional , UAT 

      Program for finding prime number in a range 

      static void prime(int LowLmt, int UpLmt)
              {
                  int c, d;
                  while (LowLmt <= UpLmt)
                  {
                      c = 0;
                      for (d = 1; d <= LowLmt; d++)
                      {
                          if (LowLmt % d == 0)
                              c++;
                      }
                      if (c == 2)
                          Console.WriteLine(LowLmt);
                      LowLmt++;
                  }
              }
      Program for reversing a number as an integer
         static int rev(int a)
                {
                    int b = 10;
                    //int c = 0;
                    int i = 0;
                    while (a > 0)
                    {
                        i *= b;
                        i += (a % b);
                        a /= b;
                       // c /= b;
                    }
                    return i;
                }  

        Program for reversing a number as string 
         static string rev(string str)
                {
                    char[] ch = str.ToCharArray(0, str.Length);
                    string str1 = "";
                    for (int i = str.Length - 1; i >= 1; i--)
                    {
                        str1 +=ch[i];
                    }
                    return str1;
                }
        Agile model, Scrum
           Agile:
          # based on iterative and incremental development
          # Customer satisfaction by rapid delivery of useful software
          # Welcome changing requirements, even late in development
          # Working software is delivered frequently
          # Close, daily co-operation between business people and developers
          # Face-to-face conversation is the best form of communication (co-location)
          # Projects are built around motivated individuals, who should be trusted
          # Self-organizing teams
          # Regular adaptation to changing circumstances

          # Agile methods break tasks into small increments with minimal planning, and do not directly involve long-term planning.
          # Iterations are short time frames (timeboxes) that typically last from one to four weeks. # Each iteration involves a team working through a full software development cycle including planning, requirements analysis, design, coding, unit testing, and acceptance testing when a working product is demonstrated to stakeholders.
          # Stakeholders produce documentation as required.

          # Team composition in an agile project is usually cross-functional and self-organizing without consideration for any existing corporate hierarchy or the corporate roles of team members.
          # Team members normally take responsibility for tasks that deliver the functionality an iteration requires.

          Scrum:
          # iterative, incremental methodology for project management often seen in agile software development
          # The main roles in Scrum are:
             1. the “ScrumMaster”, who maintains the processes (typically in lieu of a project manager)
             2. the “Product Owner”, who represents the stakeholders and the business
             3. the “Team”, a cross-functional group of about 5-9 people who do the actual analysis, design, implementation, testing, etc.

          # During each “sprint”, typically a two to four week period (with the length being decided by the team), the team creates a potentially shippable product increment (for example, working and tested software).

          # The set of features that go into a sprint come from the product “backlog”, which is a prioritized set of high level requirements of work to be done. Which backlog items go into the sprint is determined during the sprint planning meeting. During this meeting, the Product Owner informs the team of the items in the product backlog that he or she wants completed. The team then determines how much of this they can commit to complete during the next sprint, and records this in the sprint backlog.[4] During a sprint, no one is allowed to change the sprint backlog, which means that the requirements are frozen for that sprint. Development is timeboxed such that the sprint must end on time; if requirements are not completed for any reason they are left out and returned to the product backlog. After a sprint is completed, the team demonstrates how to use the software.

          # Represents a radically new approach for planning and managing software projects brings decision making authority to the level of operation properties and on certainties, scrum reduces defects , makes development process more efficient and reduces long term maintenance cost.[7]

              * What have you done since yesterday?
              * What are you planning to do today?
              * Do you have any problems that would prevent you from accomplishing your goal? (It is the role of the ScrumMaster to facilitate resolution of these impediments, although the resolution should occur outside the Daily Scrum itself to keep it under 15 minutes.)
           

            Monday, February 28, 2011

            Intw Questions Part1


            WCF
            .Net 3.5

            Safe/Unsafe code
            =================
            Unsafe code logic [Using unsafe keyword, C# code that makes low-level API calls, pointer arithmetic]
            • CLR is responsible for managing the execution of code compiled for the .NET platform. The code that satisfies the CLR at runtime in order to execute is reffered as Managed Code.
            • C# does not support pointers when creating managed code. Pointers are however both useful and necessary for some types of programming (such as system-level utilities) and C# does allow you to create and use pointers.
              • All pointer operations must be marked as unsafe since they execute outside the managed context.
             
            Safe code logic [Fixed Keyword]- Prevent GC to move certain objects


            Union All, Union, Minus in SQL
            ==============================

            Sealed class
            ============
            Prevent inheritance

            Static Constructors
            ===================
            A static constructor is used to initialize any static data. General constructors are termed as Instance constructors

            Impersonation
            =============
            The term "Impersonation" in a programming context refers to a technique that executes the code under another user context than the user who originally started an application, i.e. the user context is temporarily changed once or multiple times during the execution of an application.

            Service Contract and Operation Contract
            =======================================
            Operation contract is the name of the attribute which is applied to a method inside the interface of a WCF service

            Service contract is the name of the attribute which is applied to an interface in a WCF service


            Page life cycle
            ================
            Preinit
            init
            load
            loadPre-render
            Unload

            What’s a satellite assembly?
            ============================
             When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

            What’s the difference between System.String and System.StringBuilder classes?
            ==============================================================================
             System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed

            Every time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new allocation of space for that new object. In situations where you need to perform repeated modifications to a string, the overhead associated with creating a new String object can be costly. The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. For example, using the StringBuilder class can boost performance when concatenating many strings together in a loop

            When you use a normal string and change it, the .net framework will destroy the current string in memory and create a new one somewhere else in the memory. With a stringbuilder the object isn't destr
            oyed each time it's adapted

            SingletonClass
            ================
            The Singleton is class which only allows a single instance of itself to be created and usually gives access to the instace.

            Access Specifier in C#
            ==================
            1. Public: Any member declared public can be accessed from 
            outside the class.
            
            2. Private: it allows a class to hide its member variables 
            and member functions from other class objects and function. 
            Therefore, the private member of a class is not visible 
            outside a class. if a member is declared private, only the 
            functions of that class access the member.
            
            3. Protected: This also allows a class to hide its member 
            var. and member func. from other class objects and 
            function, except the child class. it becomes important 
            while implementing inheritance.
            
            4. Internal: Internal member can be expose to other 
            function and objects. it can be accessed from any class or 
            method defined within the application in which the member 
            is defined
            
            5. Protected Internal: it's similar to Protected access 
            specifier, it also allows a class to hide its member 
            variables and member function to be accessed from other 
            class objects and function, excepts child class, within the 
            application. used while implementing inheritance.
             
            Structure and class
            ====================
            The only difference between a structure and a 
            class is that all members in a class are private by default whereas they
             are public in a structure. 
             

            Intw Questions Part3 (Nvidia)

            Value type VS Ref Type
            -----------------------------
                * A variable that is of type value directly contains a value. Assigning a variable of type value to another

            variable of type value COPIES that value.
                * A variable of type reference, points to a place in memory where the actual object is contained. Assigning a

            variable of type reference to another variable of type reference copies that reference (it tells the new object

            where the place in memory is), but does not make a copy of the object.


                * Value types are stored on the stack.
                * Reference types are stored on the heap.


                * Value types can not contain the value null. *
                * Reference types can contain the value null.

                * Value types derive from System.ValueType.
                * Reference types derive from System.Object.

                * Changing the value of one value type does not affect the value of another value type.
                * Changing the value of one reference type MAY change the value of another reference type.
            ------------------------------
            Polymorphism/Run time polymorphism, how to acheive run time polymorphism

            Managed VS Unmanaged code
            Types of array in C#, Jagged array
            -------------------------------------
            //"jagged" array: araay of(array of int)
            int[][] j2 = new int[3][];
            j2[0] = new int[] {1, 2, 3};
            j2[1] = new int[] {1, 2, 3, 4, 5, 6};
            j2[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
            -------------------------------------
            Types of operator in C#, specifically c# operators
            --------------------------------------------------------------------------
            Primary- I++, I--
            Additive- + -
            Relational- > < >= <=
            Assignment- += -=
            Ternary ? :
            --------------------------------------------------------------------------
            How to control overflow in c#, operator to use that
            --------------------------------------------------------------------------
            Use checked where it is a possible error condition which you want to catch.
             int square(int i)
                {
                    return i * i;
                }
                void f()
                {
                    checked
                    {
                        int i = square(1000000);
                    }
                }
            --------------------------------------------------------------------------
            Virtual Functions
            -----------------------------
            a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting

            class by a function with the same signature.
            -----------------------------
            Compilation of Code in .Net
            -----------------------------
            Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts

            such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the

            operating system.
            -----------------------------
            Operator Overloading
            --------------------------------------------------------------------------
            Operator overloading permits user-defined operator implementations to be specified for operations
            &&, || They can’t be overloaded
            () (Conversion operator) They can’t be overloaded
            =, . , ?:, ->, new, is, as, size of These operators can’t be overloaded
            In C#, a special function called operator function is used for overloading purpose. These special function or

            method must be public and static.
            --------------------------------------------------------------------------

            Intw Questions Part2

            Strengths
            Weaknesses


            Technical
            =========
            Reversing a string e.g. "Something is Awesome" to
                        => Complete reverse
                        => "Awesome is Something"

            ------------------------------------------------------------------------------------------------------------------
            // Reverse the string word by word
                        String test= "Testing reversal";
                        int len = test.Length;
                        string[] strArray = test.Split(' ');
                        Console.WriteLine(strArray.Length);
                        Console.WriteLine("Reversing String");
                      
                        for(int i=strArray.Length-1; i>=0; i--)
                        {
                            if (i>0)
                                Console.Write(strArray[i] + " ");
                            else
                                Console.Write(strArray[i]);
                    }
                        // Reversing String word by word ends here
            ------------------------------------------------------------------------------------------------------------------
            Inserting a node in a link list with Test cases

            Delete a node in a link list with Test cases

            Factorial program=> With & w/o recursion
            Fibonacci program=> with & w/o recursion

            Array sorting algorithms

            Testing life cycle

            Basic powershell scripting