Exemplo n.º 1
0
        public void Add_DoesNotMutate()
        {
            var nowWatch = new DateTime(2001, 10, 10, 11, 05, 02);
            TimeProvider.Now = () => nowWatch;
            var watch = new Watch();
            var nowFiveMinutesLater = new DateTime(2001, 10, 10, 11, 10, 59);
            TimeProvider.Now = () => nowFiveMinutesLater;
            var fiveMinutesLater = new Watch();

            var newWatch = watch + fiveMinutesLater;
            Assert.AreNotSame(newWatch, watch);
            Assert.AreNotSame(newWatch, fiveMinutesLater);
            Assert.AreEqual(nowWatch, watch.WhatTimeIsIt());
            Assert.AreEqual(nowFiveMinutesLater, fiveMinutesLater.WhatTimeIsIt());
        }