示例#1
0
 public void ActivitiesEnsureICanUseObjectInitializerSyntax()
 {
     DateTime expected_time = DateTime.Now;
     Activities a_activity = new Activities
     {
         ActivityId = 1,
         ActivityName = "run",
         Distance = 2.2,
         Date = expected_time
     };
     Assert.AreEqual(1, a_activity.ActivityId);
     Assert.AreEqual("run", a_activity.ActivityName);
     Assert.AreEqual(2.2, a_activity.Distance);
     Assert.AreEqual(expected_time, a_activity.Date);
 }
示例#2
0
        public void AcitivitiesEnsureActivityHasAllTheThings()
        {
            Activities a_activity = new Activities();

            DateTime expected_time = DateTime.Now;
            a_activity.ActivityId = 1;
            a_activity.ActivityName = "run";
            a_activity.Distance = 2.2;
            a_activity.Date = expected_time;

            Assert.AreEqual(1, a_activity.ActivityId);
            Assert.AreEqual("run", a_activity.ActivityName);
            Assert.AreEqual(2.2, a_activity.Distance);
            Assert.AreEqual(expected_time, a_activity.Date);
        }
示例#3
0
        public bool CreateActivity(string activityName, double distance, Member member1)
        {
            Activities an_activity = new Activities {
                ActivityName = activityName, Distance = distance, Participant = member1, Date = DateTime.Now
            };
            bool is_added = true;

            try
            {
                Activities added_activities = _context.Activities.Add(an_activity);
                _context.SaveChanges();
            }
            catch (Exception)
            {
                is_added = false;
            }
            return(is_added);
        }
示例#4
0
 public void ActivitiesEnsureICanCreateInstance()
 {
     Activities a_activity = new Activities();
     Assert.IsNotNull(a_activity);
 }
示例#5
0
        public bool CreateActivity(string activityName, double distance, Member member1)
        {
            Activities an_activity = new Activities { ActivityName = activityName, Distance = distance, Participant = member1, Date = DateTime.Now };
            bool is_added = true;
            try
            {
                Activities added_activities = _context.Activities.Add(an_activity);
                _context.SaveChanges();

            }
            catch (Exception)
            {
                is_added = false;
            }
            return is_added;
        }