private void Init()
 {
     _provider = new UserProvider();
     _user = new User
     {
         FirstName = "Vault",
         LastName = "Boy",
         BirthDate = DateTime.Now.AddYears(-37)
     };
 }
 public void GetUserGeneration_GenerationalTimeExceeded_WithException()
 {
     using (ShimsContext.Create())
     {
         ShimDateTime.NowGet = () => new DateTime(2035, 1, 1);
         //ARRANGE
         User user = new User()
         {
             BirthDate = DateTime.Now.AddYears(-5)
         };
         UserProvider provider = new UserProvider();
         //ACT
         var gen = provider.GetUserGeneration(user);
         //ASSERT
         Assert.AreEqual("Millenials", gen);
     }
 }
        public string GetUserGeneration(User userToPutInCategory)
        {
            if ((DateTime.Now.Subtract(new DateTime(2005, 1, 1)).TotalDays / 365) > 20)
                throw new Exception("There should be a new generation!");

            if (userToPutInCategory.Age >= 70)
                return "Greatest Generation";
            if (userToPutInCategory.Age > 50 && userToPutInCategory.Age < 70)
                return "Baby Boomer";
            if (userToPutInCategory.Age > 30 && userToPutInCategory.Age <= 50)
                return "Gen X";
            if (userToPutInCategory.Age > 10 && userToPutInCategory.Age <= 30)
                return "Millenials";
            if (userToPutInCategory.Age <= 10)
                return "TBD";

            return string.Empty;
        }
        public BillingInfo GetBillingInfoByUser(User userToQuery)
        {
            IBillingProvider provider = Container.Resolve<IBillingProvider>();

            return provider.GetBillingInfo(userToQuery);
        }
 public string EstablishUserGeneration(User user)
 {
     return Provider.GetUserGeneration(user);
 }
 public UserAccount(string username, string password, User linkedUser)
 {
     Username = username;
     _password = password;
     User = linkedUser;
 }
 public BillingInfo GetBillingInfo(User user)
 {
     throw new Exception("Billing Repository is unavailable!");
     //Normally we'd call our repository to get this object
 }