public void RoundTripEpoch()
        {
            var newYears = new DateTime(2008, 1, 1, 0, 0, 0);

            long epoch = newYears.Epoch();

            DateTime fromEpoch = DateTimeUtility.FromEpoch((int)epoch);

            Assert.AreEqual(newYears, fromEpoch);
        }
        public void InspectContext(ProviderPhase phase, IOAuthContext context)
        {
            DateTime timestamp = DateTimeUtility.FromEpoch(Convert.ToInt32(context.Timestamp));
            DateTime now       = _nowFunc();

            if (now.Subtract(_maxBeforeNow) > timestamp)
            {
                throw new OAuthException(context, OAuthProblems.TimestampRefused,
                                         string.Format(
                                             "The timestamp is to old, it must be at most {0} seconds before the servers current date and time",
                                             _maxBeforeNow.TotalSeconds));
            }
            if (now.Add(_maxAfterNow) < timestamp)
            {
                throw new OAuthException(context, OAuthProblems.TimestampRefused,
                                         string.Format(
                                             "The timestamp is to far in the future, if must be at most {0} seconds after the server current date and time",
                                             _maxAfterNow.TotalSeconds));
            }
        }