Esempio n. 1
0
        public ActionResult Stats()
        {
            try
            {
                List <OwnedItemBLL> Items;
                List <ItemStats>    Model;
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL ThisUser = ctx.FindUserByEMail(User.Identity.Name);
                    if (null == ThisUser)
                    {
                        ViewBag.Exception = new Exception($"Could Not Find Record for User: {User.Identity.Name}");
                        return(View("Error"));
                    }
                    int TotalCount = ctx.ObtainCountOfItemsOwnedByUser(ThisUser.UserID);
                    Items = ctx.GetOwnedItemsRelatedToUser(ThisUser.UserID, 0, TotalCount);


                    MeaningfulCalculator mc = new MeaningfulCalculator();
                    Model = mc.ComputeStats(Items);
                }
                return(View("..\\Item\\Stats", Model));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
Esempio n. 2
0
        public void When_UsersIsNull_Expect_AverageToBeZero()
        {
            // arrange
            ThisDateTimeProvider now = new ThisDateTimeProvider(1999, 1, 1);
            MeaningfulCalculator mc  = new MeaningfulCalculator(now);

            double expected = 0;
            // act
            double actual = mc.AverageAge(null);

            // assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void When_NoUsers_Expect_AverageToBeZero()
        {
            // arrange
            ThisDateTimeProvider now = new ThisDateTimeProvider(1999, 1, 1);
            MeaningfulCalculator mc  = new MeaningfulCalculator(now);
            var    Users             = MakeSampleUsers(0);
            double expected          = 0;
            // act
            double actual = mc.AverageAge(Users);

            // assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void When_UsersIsNonNull_Expect_AverageToBeNonZero()
        {
            // arrange
            ThisDateTimeProvider now   = new ThisDateTimeProvider(1999, 1, 1);
            MeaningfulCalculator mc    = new MeaningfulCalculator(now);
            List <UserBLL>       Users = MakeSampleUsers(4);

            double expected = 0;
            // act
            double actual = mc.AverageAge(Users);

            // assert
            Assert.AreNotEqual(expected, actual);
        }
 public ActionResult Stats()
 {
     try
     {
         List <OwnedItemBLL> Items;
         List <ItemStats>    Model;
         using (ContextBLL ctx = new ContextBLL())
         {
             int TotalCount = ctx.ObtainOwnedItemCount();
             Items = ctx.GetOwnedItems(0, TotalCount);
             MeaningfulCalculator mc = new MeaningfulCalculator();
             Model = mc.ComputeStats(Items);
         }
         return(View("Stats", Model));
     }
     catch (Exception ex)
     {
         ViewBag.Exception = ex;
         return(View("Error"));
     }
 }