Ejemplo n.º 1
0
        public void TestUpdate()
        {
            IExternalSurrogate s1 = new CGuidSurrogate();
            IExternalSurrogate s2 = new CDateTimeSurrogate();
            IExternalSurrogate s3 = new CUtcDateTimeSurrogate();

            IExternalSurrogate accum = null;

            accum = CExternalSurrogatePair.Update(accum, null);
            Assert.IsNull(accum, "Updating NULL with NULL should result in NULL");

            accum = CExternalSurrogatePair.Update(accum, s1);
            Assert.AreSame(s1, accum, "After UPDATEing null with s1, the accumulator should be s1");

            accum = CExternalSurrogatePair.Update(accum, null);
            Assert.AreSame(s1, accum, "After UPDATEing the s1 accumulator with NULL, the accumulator should not have changed");


            accum = CExternalSurrogatePair.Update(accum, s2);
            Assert.AreEqual(typeof(CExternalSurrogatePair), accum.GetType(), "After UPDATEing accumulator with s2, the accumulator should now be a surrogate Pair.");

            Assert.AreSame(s1, (accum as CExternalSurrogatePair).Surrogate1, "The first surrogate of the Pair should be s1");
            Assert.AreSame(s2, (accum as CExternalSurrogatePair).Surrogate2, "The second surrogate of the Pair should be s2");


            accum = CExternalSurrogatePair.Update(accum, s3);
            Assert.AreEqual(typeof(CExternalSurrogatePair), accum.GetType(), "After UPDATEing accumulator with s3, the accumulator should still be a surrogate Pair.");

            Assert.AreEqual(typeof(CExternalSurrogatePair), (accum as CExternalSurrogatePair).Surrogate1.GetType(), "The Type of the first surrogate of the Pair should be a Pair");
            Assert.AreEqual(typeof(CUtcDateTimeSurrogate), (accum as CExternalSurrogatePair).Surrogate2.GetType(), "The Type of the second surrogate of the Pair should be the UTC Time surrogate");
        }
Ejemplo n.º 2
0
        public void TestConstructor()
        {
            IExternalSurrogate s1 = new CGuidSurrogate();
            IExternalSurrogate s2 = new CDateTimeSurrogate();

            var pair = new CExternalSurrogatePair(s1, s2);

            Assert.AreSame(s1, pair.Surrogate1, "Surrogate1 does not point to the same object");
            Assert.AreSame(s2, pair.Surrogate2, "Surrogate2 does not point to the same object");
        }