public void TestChristmaPickServiceUsingTheSequentialNumberGeneratorWithOneRuleThatIsAlwaysPassingForOddChristmasYear()
        {
            PersonCollection pickList = new PersonCollection();

              Person MaxG = new Person("Max", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555");
              Person CharlotteG = new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555");
              Person MadelineG = new Person("Madeline", "Gehred", new DateTime(1988, 4, 15), "14111111-2222-3333-4444-555555555555");
              Person CecilaG = new Person("Cecila", "Gehred", new DateTime(1990, 6, 21), "15111111-2222-3333-4444-555555555555");
              pickList.Add(MaxG);
              pickList.Add(CharlotteG);
              pickList.Add(MadelineG);
              pickList.Add(CecilaG);

              IPickListService testObj = new PickListServiceAdvanced(new SequentialNumberGenerator(pickList.Count), new TestRuleProvider(), pickList);

              XMasPickList actual = testObj.CreateChristmasPick(new DateTime(2007, 12, 25));

              XMasPick expectedFirstPick = new XMasPick(CharlotteG, MaxG);
              Assert.IsTrue((expectedFirstPick == actual[0]));

              XMasPick expectedSecondPick = new XMasPick(MaxG, CecilaG);
              Assert.IsTrue(expectedSecondPick == actual[1]);

              XMasPick expectedThirdPick = new XMasPick(CecilaG, MadelineG);
              Assert.IsTrue(expectedThirdPick == actual[2]);

              XMasPick expectedFourthPick = new XMasPick(MadelineG, CharlotteG);
              Assert.IsTrue(expectedFourthPick == actual[3]);
        }
예제 #2
0
        public void TestChristmasPickDeserialization()
        {
            Person Bob = new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555");
            Person Angie = new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555");

              XMasPick expectedPick = new XMasPick(Bob, Angie);
              XMasPick actual = null;
              byte[] serializedPickItem = ConvertStringToByteArray("<?xml version=\"1.0\"?>\r\n<XMasPick>\r\n  <Subject firstname=\"Bob\" lastname=\"Gehred\" birthday=\"7/27/1972\" id=\"21111111-2222-3333-4444-555555555555\" />\r\n  <Recipient firstname=\"Angie\" lastname=\"Gehred\" birthday=\"9/26/1971\" id=\"11111111-2222-3333-4444-555555555555\" />\r\n</XMasPick>");
              Stream testData = new MemoryStream(serializedPickItem);
              XmlSerializer xml = new XmlSerializer(typeof(XMasPick));
              actual = (XMasPick)xml.Deserialize(testData);
              Assert.AreEqual(expectedPick, actual);
        }
예제 #3
0
        public void TestChristmaPickSerialization()
        {
            Person Bob = new Person("Bob", "Gehred", new DateTime(1972, 7, 27), "21111111-2222-3333-4444-555555555555");
            Person Angie = new Person("Angie", "Gehred", new DateTime(1971, 9, 26), "11111111-2222-3333-4444-555555555555");

              XMasPick testPick = new XMasPick(Bob, Angie);

              Stream myStream = new BufferedStream(new MemoryStream(new byte[1024], true), 1024);
              if (myStream != null)
              {
            XmlSerializer xml = new XmlSerializer(typeof(XMasPick));
            xml.Serialize(myStream, testPick);
              }

              long length = myStream.Position;
              myStream.Position = 0;
              StreamReader rawData = new StreamReader(myStream);
              string actual = rawData.ReadToEnd();
              actual = actual.Substring(0, (int)length);
              Assert.AreEqual("<?xml version=\"1.0\"?>\r\n<XMasPick>\r\n  <Subject firstname=\"Bob\" lastname=\"Gehred\" birthday=\"7/27/1972\" id=\"21111111-2222-3333-4444-555555555555\" />\r\n  <Recipient firstname=\"Angie\" lastname=\"Gehred\" birthday=\"9/26/1971\" id=\"11111111-2222-3333-4444-555555555555\" />\r\n</XMasPick>", actual);
        }
예제 #4
0
 protected static bool AreEquals(XMasPick a, XMasPick b)
 {
     bool areEqual = (a.mSubject == b.mSubject);
       if (areEqual)
       {
     areEqual = (a.mRecipient == b.mRecipient) && (a.mIsSet == b.mIsSet);
       }
       return areEqual;
 }