Ejemplo n.º 1
0
    public static void CreateDemo(ObjectA person_A, ObjectB person_B)
    {
      Console.WriteLine("Enter name of first object");
      string name_A = Console.ReadLine();

      Console.WriteLine("Enter security number of first object");
      int age_A = Convert.ToInt32(Console.ReadLine());

      Console.WriteLine("Enter date of birth of first object (mm/dd/yyyy)");
      DateTime dateOfBirth_A = Convert.ToDateTime(Console.ReadLine());

      person_A.Surname = name_A;
      person_A.SecurityNumber = age_A;
      person_A.DateOfBirth = dateOfBirth_A;

      Console.WriteLine("Enter department of first object");
      string dep_A = Console.ReadLine();
      person_A.objectAEmploymentHistory.Department = dep_A;

      Console.WriteLine("Enter start date of first object (mm/dd/yyyy)");
      DateTime startDate_A = Convert.ToDateTime(Console.ReadLine());
      person_A.objectAEmploymentHistory.startDate = startDate_A;

      Console.WriteLine("Enter work hours of first object");
     double workHours_A = Convert.ToDouble(Console.ReadLine());
      person_A.objectAEmploymentHistory.HourWorked = workHours_A;


      Console.WriteLine("Enter name of second object");
      string name_B = Console.ReadLine();

      Console.WriteLine("Enter security number of second object");
      int age_B = Convert.ToInt32(Console.ReadLine());

      Console.WriteLine("Enter date of birth of second object (mm/dd/yyyy)");
      DateTime dateOfBirth_B = Convert.ToDateTime(Console.ReadLine());

      person_B.Surname = name_B;
      person_B.SecurityNumber = age_B;
      person_B.DateOfBirth = dateOfBirth_B;



      Console.WriteLine("Enter department of second object");
      string dep_B = Console.ReadLine();
      person_B.objectBEmploymentHistory.Department = dep_B;

      Console.WriteLine("Enter start date of second object (mm/dd/yyyy)");
      DateTime startDate_B = Convert.ToDateTime(Console.ReadLine());
      person_B.objectBEmploymentHistory.startDate = startDate_B;

      Console.WriteLine("Enter work hours of second object");
      double workHours_B = Convert.ToDouble(Console.ReadLine());
      person_B.objectBEmploymentHistory.HourWorked = workHours_B;      

      Console.ReadKey();
      new Auditor().CompareObjects(person_A, person_B);
    }
Ejemplo n.º 2
0
 public static void Main()
 {
   Console.WriteLine("Enter V to view demo C to create demo");
   string result = Console.ReadLine();
   if (result.ToLower().Equals("v"))
   {
     ViewDemo();
   }
   else if(result.ToLower().Equals("c"))
   {
     ObjectA person_A = new ObjectA();
     ObjectB person_B = new ObjectB();
     CreateDemo(person_A, person_B);
   }
 }
Ejemplo n.º 3
0
    private static void ViewDemo()
    {
      ObjectA person_A = new ObjectA("A", 26, new DateTime(1990, 6, 10));
      ObjectB person_B = new ObjectB("B", 10, new DateTime(2006, 7, 10));

      person_B.objectBEmploymentHistory.Department = "IT";
      person_B.objectBEmploymentHistory.startDate = new DateTime(2012, 02, 09);
      person_B.objectBEmploymentHistory.HourWorked = 38.5;

      person_A.objectAEmploymentHistory.Department = "HR";
      person_A.objectAEmploymentHistory.startDate = new DateTime(2010, 05, 09);
      person_A.objectAEmploymentHistory.HourWorked = 37.5;

      new Auditor().CompareObjects(person_A, person_B);
    }
Ejemplo n.º 4
0
    public void ObjectsDateOfBirthAndAge_AreDifferent_ReturnTwoChange()
    {
      // Arrange
      ObjectA objectA = new ObjectA("A", 10, new DateTime(2006, 8, 10));
      ObjectB objectB = new ObjectB("A", 26, new DateTime(2006, 7, 10));

      Auditor auditor = new Auditor();

      String result = "";

      // Act
      Hashtable ht = auditor.CompareObjects(objectA, objectB);
      foreach (DictionaryEntry de in ht)
      {
        result += de.Value;
      }

      // Assert
      Assert.AreEqual(result, "Change 1: Object_A: 08 10 2006 || Object_B: 07 10 2006 Change 2: Object_A: 10 || Object_B: 26 ");
    }
Ejemplo n.º 5
0
    public void ObjectsName_AreDifferent_ReturnOneChange()
    {
      //Arrange
      ObjectA objectA = new ObjectA("A", 10, new DateTime(2006, 7, 10));
      ObjectB objectB = new ObjectB("B", 10, new DateTime(2006, 7, 10));

      Auditor auditor = new Auditor();

      String result = "";

      //Act
      Hashtable ht = auditor.CompareObjects(objectA, objectB);
      foreach (DictionaryEntry de in ht)
      {
        result += de.Value;
      }

      //Assert
      Assert.AreEqual(result, "Change 1: " + "Object_A: A || Object_B: B ");

    }
Ejemplo n.º 6
0
    public  Hashtable CompareObjects(ObjectA objecta, ObjectB objectb)
    { 
      Hashtable changeHtable = new Hashtable();
      int counter = 0;
      foreach (DictionaryEntry entryA in objecta.GetHashtable())
      {

        foreach (DictionaryEntry entryB in objectb.GetHashtable())
        {
          if ((entryA.Key.Equals(entryB.Key)) && (!entryA.Value.Equals(entryB.Value)))
          {
            counter++;
            changeHtable.Add(entryA.Key, "Change "+ counter +": "+ "Object_A: " + entryA.Value + " || Object_B: " + entryB.Value + " ");
          }
        }
      }

      WriteDifference(changeHtable);
      WriteDifferenceToStream(changeHtable);

      return changeHtable;
    }